View Single Post
 
Old 04-01-2022, 08:49 PM
gmayor's Avatar
gmayor gmayor is offline Windows 10 Office 2019
Expert
 
Join Date: Aug 2014
Posts: 4,144
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

Your code simply sets a document property. It does not set the file path. To change the path, use
Code:
ChDir "path"
However it is not necessary to do that to save a document in a specific location. If you want to save a document in a specific folder you must set that folder first e.g.
Code:
Dim dtToday As String
Dim sPath As String
    sPath = Options.DefaultFilePath(wdDocumentsPath) & "\"
    dtToday = Format(Date, "ddmmyyyy")
    MsgBox sPath & "Waiver_" & dtToday & ".docx"
    ActiveDocument.SaveAs2 sPath & "Waiver_" & dtToday & ".docx"
Note that
Code:
Dim dtToday As Date
  dtToday = Date
produces the system short date format and that may result in illegal filename characters e.g. 02/04/2022 so set dtDate as a string variable and format the date to produce legal filename characters e.g 02042022 as in the previous example.
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote