How can you create a New Folder using VBA in Word

J

jlawson

I'm trying to have vba save a document to a certain sub folder. The
parent folder will already be present but I wanted vba to create a sub
folder if one did not was not present. Like creating monthly sub
folders in the parent folder. With the code I have so far Word just
tells me tha the path is not found. Here is what I have...

Sub savenewfolder()

vYear = Format(Now(), "YYYY")
vMonth = Format(Now(), "MMMM")
vvMonth = Format(Now(), "MM")
vDay = Format(Now(), "DD")
vTime = Format(Now(), "HH:mm")
vName = UserForm1.uname

ChangeFileOpenDirectory "S:\Patient Access Forms\" & vYear & " " &
vMonth & "\"
ActiveDocument.SaveAs FileName:=vYear & vvMonth & vDay & " " &
vTime & vName & ".doc", _
FileFormat:=wdFormatDocument, LockComments:=False,
Password:="", _
AddToRecentFiles:=True, WritePassword:="",
ReadOnlyRecommended:=False, _
EmbedTrueTypeFonts:=False, SaveNativePictureFormat:=False,
SaveFormsData _
:=False, SaveAsAOCELetter:=False
End Sub
 
D

Doug Robbins - Word MVP

Check out the MkDir function

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top