create a pdf in landscape view

PeterBaileyUk
PeterBaileyUk used Ask the Experts™
on
I am using this code which creates the pdf but its in portrait mode and cuts off some of the fields. How do I make it create a landscape pdf?


DoCmd.OutputTo acOutputQuery, "QryDateStrings", _
 acFormatPDF, , "C:\Users\peter\desktop\Employee.PDF", True

Open in new window

QryDateStrings.pdf
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2016

Commented:
I am using this code.. What code?

Author

Commented:
I can see it on the screen, the new interface is weird.

[code]DoCmd.OutputTo acOutputQuery, "QryDateStrings", _
 acFormatPDF, , "C:\Users\peter\desktop\Employee.PDF", True

Open in new window

[/code]
Top Expert 2016

Commented:
Added ACCESS topic

which version of MS Access?
How to Generate Services Revenue the Easiest Way

This Tuesday! Learn key insights about modern cyber protection services & gain practical strategies to skyrocket business:

- What it takes to build a cloud service portfolio
- How to determine which services will help your unique business grow
- Various use-cases and examples

Author

Commented:
Office 365

Author

Commented:
I just created a report using the query and exported that manually to pdf and everything is fine that way.

Maybe there is a way to do that in vba
Function FileExist(FileFullPath As String) As Boolean
  Dim value As Boolean
  value = False
  If Dir(FileFullPath) <> "" Then
    value = True
  End If
  FileExist = value
End Function

Public Sub cmd_exportPDF_Click()
 
  Dim fileName As String, fldrPath As String, filePath As String
  Dim answer As Integer

  fileName = "Statement" 'filename for PDF file*
  fldrPath = "C:\Users\peter\OneDrive\Desktop\PDF" 'folder path where pdf file will be saved *

  filePath = fldrPath & "\" & fileName & ".pdf"
 
  'check if file already exists
  If FileExist(filePath) Then
    answer = MsgBox(prompt:="PDF file already exists: " & vbNewLine & filePath & vbNewLine & vbNewLine & _
      "Would you like to replace existing file?", buttons:=vbYesNo, Title:="Existing PDF File")
    If answer = vbNo Then Exit Sub
  End If
 
  On Error GoTo invalidFolderPath
  DoCmd.OutputTo objecttype:=acOutputReport, objectName:="RptDatesStatement", outputformat:=acFormatPDF, outputFile:=filePath
 
  MsgBox prompt:="PDF File exported to: " & vbNewLine & filePath, buttons:=vbInformation, Title:="Report Exported as PDF"
  Exit Sub
 
invalidFolderPath:
  MsgBox prompt:="Error: Invalid folder path. Please update code.", buttons:=vbCritical
 
End Sub

Open in new window

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial