Hi, my name isXXXXX would be happy to help you troubleshoot the PDF to landscape mode problem you have. Let me know when you are ready to start?
OK great. When I read your problem description a question jumped into my head.
I've had this problem before and the fix was really easy so here's hoping that the same fix applies here.
Can you go check the page formatting of your excel document?
Page layout - orientation - landscape
I don't think this is easy. I've been trying for years. Yes the page setup is set for Landscape. As I said the opened pdf is in Landscape but the print mode is Portrait.
Yes, please allow me time to finish my instructions or would you rather talk to another expert?
How do I know when you're done?
Hi, I'm sorry but I am going to opt out for obvious reasons.
Sorry if I offended you. I really thought you were done asking if the setup was Landscape or not
I'm creating the pdf for a general audience so I'm stuck with Adobe Reader.
I'm mot the guy reading it, I'm the guy creating it. I don't know what application it will be opened in but must assume that it's Adobe Reader.
Yes, that's true. It's very frustrating as I create beautiful Landscape pdf's and invariably someone will print 50 copies in the default Portrait mode.
They should set Landscape when they print, but usually just click on print and take what they get. I want to force printing in Landscape mode. I know this can be done with the full Adobe where printing in Landscape can be embedded into the document. . What I'm looking for is a vba hack to do this.
It's certainly possible if it can be done in Adobe. For example, I have code to force the pdf to open in full screen mode. Are there vba experts available to look at this?
I’m Rachel, and I’m moderator for this topic. It seems the professional has left this conversation. This happens occasionally, and it's usually because the professional thinks that someone else might be a better match for your question. I've been working hard to find a new professional to assist you right away, but sometimes finding the right professional can take a little longer than expected.
I was checking to see if you had already found your answer or if you still needing assistance from another one of the professionals? Please let me know if you wish to continue waiting or if you would like for us to close your question.Also remember that JustAnswer has a multitude of categories to help you with all your needs from Health, Pets, Computers, Taxes, Cars, Finance, Law, to Home Improvement, and more.
Yes I'd like to continue. This issue requires an expert in Excel VBA.
Thank you, XXXXX XXXXX continue to look for a professional to assist you. Please let me know if I can be of any further assistance while you wait.
I do have the page setup as Landscape and it does open in landscape when viewing the pdf. My problem is that it still prints in portrait. I want to somehow embed landscaped printing as default into the pdf.
This is my code:
ActiveSheet.PageSetup.Orientation = xlLandscape
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _ ThisWorkbook.Path & "Try PDF.pdf", Quality:=xlQualityStandard _ , IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:= _ False
When I open it, the print mode is the default of portrait.
My problem is not how the pdf shows when opening, it is how it is printed.
I need to somehow embed instructions to print in landscape.
This can be done in Adobe so I'm sure there must be a way with vba.
How can I pursue this?
***Using Acrobat Standard or Pro
Following Change will accomplish what you are after:
File -> Properties -> Advanced -> Print Dialog Presets -> Check "Paper Source by Page Size" -> Click OK -> Save
***Using Acrobat SDK
Use of Acrobat SDK is not an option without an actual installation of Acrobat itself. Following code lets access to PDF print parameters and enable the "choose paper size by pdf source" option.
Dim SampleFilePath As String
Dim rc As Integer
Dim pdDoc As Acrobat.AcroPDDoc
Dim jso As Object
Dim pp As Object
Dim FV As Object
pdDoc = CreateObject("AcroExch.PDDoc")
If pdDoc Is Nothing Then
MsgBox ("Failed to create Acrobat PDDoc object. Is Acrobat Installed properly?")
' Open the source PDF document
SampleFilePath = "Test.pdf"
rc = pdDoc.Open(SampleFilePath)
If rc -1 Then
MsgBox ("Failed to open PDF document " & SampleFilePath)
jso = pdDoc.GetJSObject
pp = jso.getPrintParams()
FV = pp.Constants.flagValues
pp.flags = (FV.setPageSize + FV.suppressCenter + FV.suppressRotate)
***Without Using Acrobat
Alternatively, excel to postscript to pdf via ghostscript which is the open source engine that serves the same purpose as adobe's distiller and which is used by all of Adobe's competition including FoxIt would be the avenue. Although not sure if this route is cost-effective as it would an effort to put it together when Adobe is available as a subscription as well.
Buying Acrobat is not an option for me. I've tried the free pdf Creator and have the same problem. I'm looking for a way to change the print settings with VBA. I think it must be possible as I have code which modifies a pdf document's properties to have it open in full screen mode.
Sub SetFullScreenPDF(ByVal original As String, ByVal fullscreen As String)Const BUFSIZ As Long = 4096Dim Remainder As LongDim hOriginal As IntegerDim hFullscreen As IntegerDim StrBuffer As StringDim Header As StringDim Buffer() As ByteDim Offset As LongDim Regex As Object 'RegExpDim Fso As Object 'FileSystemObject
hOriginal = FreeFileOpen original For Input Access Read Lock Write As #hOriginalLine Input #hOriginal, StrBuffer 'get the first lineHeader = StrBuffer & vbCrLfDo While True Offset = Seek(hOriginal) 'Loc() returns position/128 for sequential files If LCase(StrBuffer) Like "*endobj*" Then Exit Do End If Line Input #hOriginal, StrBuffer 'get the next line Header = Header & StrBuffer & vbCrLfLoopClose hOriginal
Set Regex = CreateObject("VBScript.RegExp") 'New RegExpRegex.Pattern = "/Type[\s\r\n]*/Catalog"Regex.MultiLine = TrueHeader = Regex.Replace(Header, "/Type/Catalog/PageMode/FullScreen")Set Regex = Nothing
hOriginal = FreeFileOpen original For Binary Access Read Lock Write As #hOriginalSeek hOriginal, Offset
Set Fso = CreateObject("Scripting.FileSystemObject") 'New FileSystemObjectIf Fso.FileExists(fullscreen) Then Fso.DeleteFile (fullscreen) 'Get permission denied errors hereEnd IfSet Fso = Nothing
hFullscreen = FreeFileOpen fullscreen For Binary Access Write Lock Read Write As #hFullscreenPut #hFullscreen, , Header
'copy original fileRemainder = LOF(hOriginal) - Offset + 1 'VB6 offsets are 1-basedReDim Buffer(1 To BUFSIZ)Do While Remainder > BUFSIZ Get #hOriginal, , Buffer Put #hFullscreen, , Buffer Remainder = Remainder - BUFSIZLoopIf Remainder > 0 Then ReDim Buffer(1 To Remainder) Get #hOriginal, , Buffer Put #hFullscreen, , Buffer Remainder = 0End IfClose hOriginal, hFullscreen
I don't understand the PickTrayByPdfSize. I want to Print in Landscape mode from whatever the active tray is.
Does PdfCreator create the desired file?
So I have to create a pdf v1.7 document. Any ideas?
Hello! I have written code in java using an external library from a 3rd party and it seems to do the trick ie I am able to mod the pdf file from excel vba and add to it the pdf1.7 object for handling the "choose paper size by PDF source" option in Adobe. I can try and see if excel vba will also function using this library's vb dlls or I can give you java code. As a matter of fact this now powers me to do anything I want to the pdf without Acrobat. Let me know. :)
Thanks for your persistence!! I don't know how to proceed. Can you give me an executable I can call with the shell function that will do what I want?
Or is it best to try using vba?
I ran the program and created a new pdf. It still has the print mode set for Portrait.
Is the "choose paper size by PDF source" clicked on when the print dialog comes up in Adobe Reader?
This is great!!! "choose paper size by PDF source" is clicked. If my pdf was saved as Landscape, it prints in Landscape whether or not the orientation is selected as Landscape. Same for Portrait. I think this is exactly what I want. I have it working from the shell command.
Thanks so much for your effort.
You are most welcome!