I'm attempting to use this code found here:
Sub SaveAllOpenDocsAsDocx()
For Each aDoc In Application.Documents
aDoc.SaveAs FileName:=aDoc.FullName & ".doc", FileFormat:=wdFormatDocument
aDoc.Close
Next aDoc
End Sub
I'd like to save any open word documents to a specific folder path, how would I go about changing
FileName:=aDoc.FullName
to a specific locations e.g. C:\Users\joe.blog\Desktop\Backup
CodePudding user response:
Using FullName property includes the original path.
You need to pull out the Filename and append that to your path
Something like this
Sub SaveAllOpenDocsAsDocx()
Const MY_LOCATION = "C:\Users\joe.blog\Desktop\Backup\"
Dim myFileLocation As String
For Each aDoc In Application.Documents
myFileLocation = MY_LOCATION & aDoc.Name & ".doc"
aDoc.SaveAs FileName:=myFileLocation, FileFormat:=wdFormatDocument
aDoc.Close
Next aDoc
End Sub