'VBA save as Filepath
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
Solution 1:[1]
Using FullName property includes the original path.
You need to pull out the Filename using the Name property 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
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
