I want to print my document under current and folder using "Application.PrintOut" method, I don't want by "ExportAsFixedFormat" because I have issue with this method.
I googled and found some codes, but I can't assembled them
Code: Select all
Sub SaveAsPDF()
Dim sPrinter As String
Dim sRange As String
On Error GoTo lbl_Exit
sPrinter = Application.ActivePrinter
ActivePrinter = "Microsoft Print to PDF"
sRange = All
Application.PrintOut FileName:="", _
range:=wdPrintRangeOfPages, _
Item:=wdPrintDocumentWithMarkup, _
copies:=1, _
Pages:=sRange, _
PageType:=wdPrintAllPages, _
collate:=True, _
Background:=False, _
PrintToFile:=False, _
PrintZoomColumn:=0, _
PrintZoomRow:=0, _
PrintZoomPaperWidth:=0, _
PrintZoomPaperHeight:=0
lbl_Exit:
Application.ActivePrinter = sPrinter
Exit Sub
End Sub
Code: Select all
Dim strDocName As String
Dim strPath As String
Dim intPos As Integer
Start:
'Find position of extension in filename
strDocName = ActiveDocument.Name
strPath = ActiveDocument.path & "\"
intPos = InStrRev(strDocName, ".")
If intPos = 0 Then
ActiveDocument.Save
GoTo Start
End If
strDocName = Left(strDocName, intPos - 1)
strDocName = strPath & strDocName & ".pdf"
Code: Select all
Application.PrintOut FileName:=strDocName
Any suggestion, please
Thanks