Results 1 to 7 of 7

Thread: How to open "Save print output as" -window having a file name from variable? MS Word

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2021
    Posts
    4

    How to open "Save print output as" -window having a file name from variable? MS Word

    Hello all!

    I have a simple form with a dozen fields in a MS Word document that I need to print to a pdf file. I'm looking for a solution to end up with a "Save print output as" -window suggesting a name concatenated from three fields in the form.

    I've managed to print the file with the concatenated name, but I do not know how to let the user choose the destination folder.

    My code has the name concatenated
    strDocName = Replace(strDocName, Chr(32), "")

    I'd like to keep my code as simple and clear as possible.
    What would be the best way to proceed from here?
    Any ideas are very much appreciated!

    Kind regards,
    VBA dummy

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: How to open "Save print output as" -window having a file name from variable? MS W

    but I do not know how to let the user choose the destination folder.
    show a browseforfolder dialog, or a folderpicker dialog if available
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  3. #3

    Thread Starter
    New Member
    Join Date
    Jan 2021
    Posts
    4

    Re: How to open "Save print output as" -window having a file name from variable? MS W

    Thank you!

    That seems a very good idea. I played around with it a little, but I did not find a way to "paste" the strDocName in the FolderPicker's name-field. Could you please give me a hint, how to do that?

    Kind regards,
    VBA dummy

  4. #4
    PowerPoster jdc2000's Avatar
    Join Date
    Oct 2001
    Location
    Idaho Falls, Idaho USA
    Posts
    2,393

    Re: How to open "Save print output as" -window having a file name from variable? MS W


  5. #5

    Thread Starter
    New Member
    Join Date
    Jan 2021
    Posts
    4

    Re: How to open "Save print output as" -window having a file name from variable? MS W

    Thank you!

    I will examine these links.

  6. #6
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: How to open "Save print output as" -window having a file name from variable? MS W

    you can use like
    Code:
        savfol = CreateObject("shell.application").browseforfolder(0, "Select FOLDER to save to", &H4001, "").self.Path
    strDocName = Replace(strDocName, Chr(32), "")
    activedocument.saveAs savfol & "\" & strdocname
    note while the above example does show filenames in the dialog (which can be changed with the parameters) only folders can be selected, also if the user presses cancel and error will occur, this should be handled to cancel the save operation
    change the document object if required
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  7. #7

    Thread Starter
    New Member
    Join Date
    Jan 2021
    Posts
    4

    Re: How to open "Save print output as" -window having a file name from variable? MS W

    Excellent, thank you very much!
    This I shall definitely try

Posting Permissions

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



Click Here to Expand Forum to Full Width