I have VBA enabled template that will be used by the team as report template. i.e. teammates will use this file to generate their files without overwriting original file. Now the vba that I am looking for should in naming the file and saving it a docm (because there is another code which user should run just before printing) to a specific folder. I created following code but I keep getting following error:
" Rune-Time error '4198': Command failed"
Looking for your help please in fixing this issue.
Sub SaveReport()
Dim Customer As String, Contract As String, ReportDate As String, strFilename As String, Temp_Folder As String
Temp_Folder = "\\FSP-FS\Customer Files\ZZZ\"
Customer = ThisDocument.SelectContentControlsByTitle("Customer_Name")(1).Range.Text
Contract = ThisDocument.SelectContentControlsByTitle("ContractNo")(1).Range.Text
ReportDate = ThisDocument.SelectContentControlsByTitle("Report_Date")(1).Range.Text
strFilename = Temp_Folder & Customer & " - " & Contract & " - " & ReportDate & ".docm"
ThisDocument.SaveAs2 FileName:=strFilename, FileFormat:=Word.WdSaveFormat.wdFormatFlatXMLMacroEnabled
End Sub