#1
|
|||
|
|||
Save As PDF from UserForm Issue
Hello,
Essentially, the UserForm that loads when the Document is opened allows you to save the document as a PDF if the PDFCheck (CheckBox) is selected. All of the VBA works as intended if you execute from the Console. However, the UserForm does not seem to execute the SaveAsPDF Sub when the UserForm first loads. Why? I have attached an example of the document. |
#2
|
||||
|
||||
The principal reason is that the form is named frm in the calling code:
Dim frm As New BOSForm but you have referred to it as BOSForm in the form code, and as that doesn't effectively exist, the code is ignored. Your userform doesn't display the check box fully, and it has no cancel button. Both are addressed in the attached. I was puzzled how you were able to use content controls in a DOC format document, until I checked and found that this is a DOCM format document with the extension renamed as DOC. There is no good reason (apart from enabling it to be attached to a message in this forum) to do this and it can cause problems, so use the correct extension (and use zip to attach it). The attached does create the PDF.
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
#3
|
|||
|
|||
Wow! Thank you for the important tip that I will use in many situations.
Didn't even think of a Cancel button. Yes, the only reason I changed the extension was for upload to this forum. |
#4
|
|||
|
|||
I will post a new thread if appropriate , but the other issue I am having is that the PDF document doesn't save in the same location as the source file. What did I do wrong?
|
#5
|
||||
|
||||
I modified the PDF module so that it should now save to the same folder as the document, unless you are using the document as a template in which case the new document won't have a path. If you are doing that either save the document first, or change the line
strFilename = ActiveDocument.Path & _ to strFilename = ThisDocument.Path & _ which will save the PDF in the same folder as the 'template'.
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
#6
|
|||
|
|||
Thanks! I am using Tapatalk to use this forum, can I get on the PC to mark as solved or give you points? I am relatively new to the forum.
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Can't save userform macro from 2003 to 2010 | billy8b8 | Word VBA | 1 | 07-26-2014 07:58 PM |
Is it possible to take an input from a UserForm in one document to a UserForm in a do | BoringDavid | Word VBA | 5 | 05-09-2014 09:08 AM |
When I try to save an existing word doc, save as pops up and will not save... | samanthab | Word | 3 | 01-19-2013 06:27 AM |
PPT save issue - can't restore previous copy? | GrahamBerry | PowerPoint | 1 | 04-23-2012 10:33 AM |
Microsoft Excel Save As Address Bar Issue | Kazuma5201 | Excel | 0 | 11-03-2011 08:58 AM |