none
Save word document in specific folder with specific filename from document RRS feed

  • Question

  • Hi all,

    I have very basic knowledge and need a lot of help.

    Basically I have created a quotation letter and have managed to create a macro with the help of the internet so the quotation number increases each time a new quote template is opened. I now need another macro (I believe) to save this document in a specific folder with the filename Quotation Number (and whichever number quote we are on).

    As I have very basic understanding I need this set you very plainly please.

    Thanks

    Wednesday, October 15, 2014 11:01 AM

Answers

  • Assuming that everything else in the macro is working to your satisfaction you could simply add the following code between the "End With" and "End Sub" command lines.

    ActiveDocument.SaveAs FileName:=Options.DefaultFilePath(wdDocumentsPath) & "\MyInvoiceName" & InvNum
    
    Hope this helps


    Kind Regards, Rich ... http://greatcirclelearning.com

    Wednesday, October 15, 2014 12:23 PM

All replies

  • It would be helpful if you shared the macro code you are using. With that I am sure someone here will be able to show you where the most appropriate place to add the ActiveDocument.SaveAs FileName:=xyz.docx code that you need.

    Kind Regards, Rich ... http://greatcirclelearning.com

    Wednesday, October 15, 2014 11:34 AM
  • To get the quote number to increase I found this

    Sub AutoNew()
    Dim InvoiceFile As String, InvNum As String
    'Save ini file in the Word startup folder.
    InvoiceFile = Options.DefaultFilePath(wdStartupPath) & "\Invoice.ini"
    'or, by using the following line, the Workgroup folder
    'InvoiceFile = Options.DefaultFilePath(wdWorkgroupTemplatesPath) & "\Invoice.ini"
    InvNum = System.PrivateProfileString(InvoiceFile, "InvoiceNumber", "InvNum")
    'If there is no InvoiceNumber reference in the ini file
    'Create one and set the number to 1, otherwise increment the number
    If InvNum = "" Then
      InvNum = 1
    Else
      InvNum = InvNum + 1
    End If
    System.PrivateProfileString(InvoiceFile, "InvoiceNumber", "InvNum") = InvNum
    With ActiveDocument
      .CustomDocumentProperties("InvNum") = InvNum
      .Fields.Update
    End With
    End Sub

    To save using this increasing number I am stuck and have nothing

    Wednesday, October 15, 2014 11:37 AM
  • Assuming that everything else in the macro is working to your satisfaction you could simply add the following code between the "End With" and "End Sub" command lines.

    ActiveDocument.SaveAs FileName:=Options.DefaultFilePath(wdDocumentsPath) & "\MyInvoiceName" & InvNum
    
    Hope this helps


    Kind Regards, Rich ... http://greatcirclelearning.com

    Wednesday, October 15, 2014 12:23 PM
  • Hello,

    You can try to use a Macro Recorder available in Word. See Record or run a macro for more information. The required VBA code will be generated automatically for you.

    Wednesday, October 15, 2014 1:23 PM