hello,
I have created with the help of searching and research a macro which will pull info inputted in the file (which is an invoice) such as address, date, and invoice number from Content control forms.
After much trial and error I have the macro working, however not to a T yet.
It is supposed to pop up a save as dialog and ask where the file should be saved. It does this, however it also saves it to the first location that is opened (or last opened location).
I tried removing and re-arranging the last statements of the macro without any luck. All I want it to do is pull the info to automatically create the file name and then ask where it should be saved (so it can be put in the corresponding folder and keep things organized).
Here's the script I have and the lines in RED are the ones that I believe need changing. Please help
Sub saveasinvnumnamedate()
'
' saveasinvnumnamedate Macro
'
'
Dim strINVNUM As String, strADDRESS As String, strDATE As String
strINVNUM = ActiveDocument.SelectContentControlsByTitle("INVNUM")(1).Range.Text
strADDRESS = ActiveDocument.SelectContentControlsByTitle("ADDRESS")(1).Range.Text
strDATE = ActiveDocument.SelectContentControlsByTitle("DATE")(1).Range.Text
Dim strFilename As String
strFilename = "INVOICE" & " " & strINVNUM & " " & strADDRESS & " " & Format(strDATE, "MMM d, yyyy") & ".docx"
ActiveDocument.SaveAs strFilename
Dialogs(wdDialogFileSaveAs).Show
End Sub
I have created with the help of searching and research a macro which will pull info inputted in the file (which is an invoice) such as address, date, and invoice number from Content control forms.
After much trial and error I have the macro working, however not to a T yet.
It is supposed to pop up a save as dialog and ask where the file should be saved. It does this, however it also saves it to the first location that is opened (or last opened location).
I tried removing and re-arranging the last statements of the macro without any luck. All I want it to do is pull the info to automatically create the file name and then ask where it should be saved (so it can be put in the corresponding folder and keep things organized).
Here's the script I have and the lines in RED are the ones that I believe need changing. Please help
Sub saveasinvnumnamedate()
'
' saveasinvnumnamedate Macro
'
'
Dim strINVNUM As String, strADDRESS As String, strDATE As String
strINVNUM = ActiveDocument.SelectContentControlsByTitle("INVNUM")(1).Range.Text
strADDRESS = ActiveDocument.SelectContentControlsByTitle("ADDRESS")(1).Range.Text
strDATE = ActiveDocument.SelectContentControlsByTitle("DATE")(1).Range.Text
Dim strFilename As String
strFilename = "INVOICE" & " " & strINVNUM & " " & strADDRESS & " " & Format(strDATE, "MMM d, yyyy") & ".docx"
ActiveDocument.SaveAs strFilename
Dialogs(wdDialogFileSaveAs).Show
End Sub