Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 03-04-2024, 01:43 PM
Jakov93 Jakov93 is offline Adjust Page Size Using PrintOut Method for File Print to PDF by VBA Windows 10 Adjust Page Size Using PrintOut Method for File Print to PDF by VBA Office 2010
Advanced Beginner
Adjust Page Size Using PrintOut Method for File Print to PDF by VBA
 
Join Date: Jul 2021
Posts: 45
Jakov93 is on a distinguished road
Default Adjust Page Size Using PrintOut Method for File Print to PDF by VBA

Hi,
I use this code to print the document by "Application.PrintOut" method to PDF file, I don't want it by "ExportAsFixedFormat" because I have an issue with this method (italic text loses formatting).
Code:
Sub SaveAsPDF()
    Dim sPrinter As String
    Dim strDocName As String
    Dim strPath As String
    Dim intPos As Integer
    'Find position of extension in filename
    strDocName = ActiveDocument.Name
    strPath = ActiveDocument.Path & "\"
    intPos = InStrRev(strDocName, ".")
    strDocName = Left(strDocName, intPos - 1)
    strDocName = strPath & strDocName & ".pdf"
    On Error GoTo lbl_Exit
    sPrinter = Application.ActivePrinter
    ActivePrinter = "Microsoft Print to PDF"
    Application.DisplayAlerts = False
    ActiveDocument.PrintOut _
        OutputFileName:=strDocName, _
        PrintToFile:=True
lbl_Exit:
    Application.DisplayAlerts = True
    Application.ActivePrinter = sPrinter
    Exit Sub
End Sub
The code works perfectly, but the only problem is the size of the output file is not as my document size


I always use A4 (210*297 mm), when I use ExportAsFixedFormat method, the output file is the same size as my document size,
but when I use "Application.PrintOut" method, the output file size is 215*279 mm, which is different from A4 size and causes some problems when printing on paper.
I changed the default paper size in "Microsoft Print to PDF" printer, but the problem persists, (see attached files).
Test_PrintOut_Method.pdf
Test_ExportAsFixedFormat_Method.pdf
So how to fix this issue?
Thanks
Reply With Quote
  #2  
Old 03-04-2024, 03:08 PM
Guessed's Avatar
Guessed Guessed is offline Adjust Page Size Using PrintOut Method for File Print to PDF by VBA Windows 10 Adjust Page Size Using PrintOut Method for File Print to PDF by VBA Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,977
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

I'm guessing that the default paper size for that particular printer driver must be set to US Letter instead of A4.

Have you had a look at the default Printer Settings in Windows for that driver?
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #3  
Old 03-04-2024, 09:22 PM
Jakov93 Jakov93 is offline Adjust Page Size Using PrintOut Method for File Print to PDF by VBA Windows 10 Adjust Page Size Using PrintOut Method for File Print to PDF by VBA Office 2010
Advanced Beginner
Adjust Page Size Using PrintOut Method for File Print to PDF by VBA
 
Join Date: Jul 2021
Posts: 45
Jakov93 is on a distinguished road
Default

Quote:
Originally Posted by Guessed View Post
I'm guessing that the default paper size for that particular printer driver must be set to US Letter instead of A4.
Andrew,
No such option is available from the printer settings, instead, I set it to letter but also no change
123.png
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with page number printout on booklet file in word2007 kenbrash Word 5 09-12-2023 03:59 PM
worksheet row to print on two or more printout lines rh62 Excel 1 06-18-2017 12:55 PM
The best practice to print 20,000 rows of 6-columns each in pdf landscape A3 page size while to repe Majdoleen Excel 0 04-25-2017 01:02 PM
Adjust Page Size Using PrintOut Method for File Print to PDF by VBA Want to print a file on a page size of 4.25"x5.5" noname Word 1 11-23-2014 10:55 PM
Adjust Page Size Using PrintOut Method for File Print to PDF by VBA vba word 2003: printout prints only the first page of the file kar64 Word VBA 2 02-15-2013 02:42 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 04:11 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft