Share via

Create a folder

David Rose 76 Reputation points
2022-01-02T18:31:28.983+00:00

I have written a Word template in VBA that creates a document that has to be saved to a particular folder. The code for saving is:

Set FD = Application.FileDialog(msoFileDialogSaveAs)
With FD
.InitialFileName = strLocation
.Show
.Execute
End With

where strLocation defines the location and folder in which the document is to be saved.

If the folder is not found, I would like the VBA coding to detect that and create the folder, then save the document to that folder. I am not sure how to accomplish this in VBA. All help is truly appreciated.

TIA
David

Developer technologies | Visual Basic for Applications

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.