Is there a way to change the format of how the PDF is being printed like landscape? I have 9 columns that I want to print but only getting 4

APInfa

New Member
Joined
Aug 2, 2021
Messages
7
Office Version
  1. 365
Platform
  1. Windows
I would like to make all 9 columns print on the pdf. Is there a command to switch it to landscape or another horizontal page to fit all the columns on it? Here is the code I am using:

Sub SavetoPDF
MsgBox "Please save changes as PDF: yyyymmdd_hhmm"
Dim wsA As Worksheet
Dim wbA As Workbook
Dim strTime As String
Dim strName As String
Dim strPath As String
Dim strFile As String
Dim strPathFile As String
Dim myFile As Variant

Set wbA = ActiveWorkbook
Set wsA = ActiveSheet
strTime = Format(Now(), "yyyymmdd\_hhmm")

'get active workbook folder, if saved
strPath = wbA.Path
If strPath = "" Then
strPath = Application.DefaultFilePath
End If
strPath = strPath & "\"

'replace spaces and periods in sheet name
strName = Replace(wsA.Name, " ", "")
strName = Replace(strName, ".", "_")

'create default name for savng file
strFile = strName & "_" & strTime & ".pdf"
strPathFile = strPath & strFile

'use can enter name and
' select folder for file
myFile = Application.GetSaveAsFilename _
(InitialFileName:=strPathFile, _
FileFilter:="PDF Files (*.pdf), *.pdf", _
Title:="Select Folder and FileName to save")

'export to PDF if a folder was selected
If myFile <> "False" Then
wsA.ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:=myFile, _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=True
'confirmation message with file info
MsgBox "PDF file has been created: " _
& vbCrLf _
& myFile
End If
End Sub
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
I would like to make all 9 columns print on the pdf. Is there a command to switch it to landscape
Insert this line just before the wsA.ExportAsFixedFormat _ line:
VBA Code:
    wsA.PageSetup.Orientation = xlLandscape
Please use VBA code tags.
 
Upvote 0
Insert this line just before the wsA.ExportAsFixedFormat _ line:
VBA Code:
    wsA.PageSetup.Orientation = xlLandscape
Please use VBA code tags.
Is there actually a way to format the text to fit to page? It is still having issues with formatting it all on one page.
 
Upvote 0
Try this instead:
VBA Code:
        With wsA.PageSetup
            .Orientation = xlLandscape
            .Zoom = False
            .FitToPagesTall = 1
            .FitToPagesWide = 1
        End With
 
Upvote 0
Solution

Forum statistics

Threads
1,224,507
Messages
6,179,176
Members
452,893
Latest member
denay

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top