-
Jan 7th, 2021, 06:39 AM
#1
Thread Starter
New Member
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
-
Jan 7th, 2021, 03:21 PM
#2
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
-
Jan 11th, 2021, 07:26 AM
#3
Thread Starter
New Member
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
-
Jan 11th, 2021, 10:51 AM
#4
Re: How to open "Save print output as" -window having a file name from variable? MS W
-
Jan 11th, 2021, 02:05 PM
#5
Thread Starter
New Member
Re: How to open "Save print output as" -window having a file name from variable? MS W
Thank you!
I will examine these links.
-
Jan 11th, 2021, 03:11 PM
#6
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
-
Jan 11th, 2021, 03:42 PM
#7
Thread Starter
New Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|