Your code ends with End Sub, but the corresponding line
Sub macroname()
at the beginning is missing.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.
Your code ends with End Sub, but the corresponding line
Sub macroname()
at the beginning is missing.
Based on your previous topic, insert the line
Private Sub CommandButton1_Click()
at the top of the code.
Try
strFileName:= ActiveDocument.Name or
strFileName: =ActiveDocument.FullName
Let the export as pdf procedure handle the extension. At worst, I expect you will end up with it tacked onto .docx as in myFileName.docx.pdf.
Both Doug and Hans are much more proficient and competent vba coders than am I.
Based on your previous topic, insert the line
Private Sub CommandButton1_Click()
at the top of the code.
Looking at this snippet from the previous thread,
.
you need one of the two lines in the box, but not both. If you restore the first line, the macro will run when you click the button named CommandButton1 (assuming this code is in a userform that contains such a button). If you restore the second line, the macro will run only when you manually choose to start it (assuming that you have a shortcut or QAT button assigned to it, or use the Alt+F8 "Macros" dialog).
Also, if you type either line into the macro editor, VBA will automatically follow it with an End Sub statement, which you'll have to delete because there's already one at the end of the macro.