View Single Post
 
Old 10-19-2014, 12:53 AM
gmayor's Avatar
gmayor gmayor is offline Windows 7 64bit Office 2010 32bit
Expert
 
Join Date: Aug 2014
Posts: 4,142
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

The message says Compile Error - expected Function or Variable and highlights SaveAs2.

SaveAs2 incidentally is not available in Word 2007, but the OP says 2013 and in that version the following change doesn't produce the error.

Code:
With ActiveDocument
        strfname = "C:\Users\" & Environ("Username") & "\Documents\" & .SelectContentControlsByTitle("Title")(1).Range.Text & ".PDF"
        .SaveAs2 Filename:=strfname, FileFormat:=wdFormatPDF
End With
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote