Consulting

Results 1 to 7 of 7

Thread: VBA to save from template dotm to VBA enabled file docm

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    VBAX Regular
    Joined
    Nov 2018
    Posts
    14
    Location

    Question VBA to save from template dotm to VBA enabled file docm

    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
    Last edited by macropod; 11-04-2018 at 02:46 AM. Reason: Repaired code structure

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •