Hi.
I have working code here that I can use to open or print a pdf.
When I run the testPrint subroutine, the document prints. Problem is it prints with the default print settings on size 8.5x11 paper. The document I'm printing does not fit correctly on this size paper.
I have saved a print settings file "BP_11x17.sav" which is currently in the same directory as the pdf file (my desktop).
I need to know how to tell Acrobat Reader to use this .sav file for the print settings.
Can anyone tell me how to do this?
Please consider:
*The excel file containing this code will be executed from multiple users at multiple workstations.
*All have acrobat reader, although some may have different versions then others.
*Location of the Acrobat Reader exe may not always be in same directory.
*Location of the print settings (BP_11x17.sav) will always be in the same directory, and will be accessible by everyone.
*I have no control over how each users VBA reference library is setup.
These concerns are why I am using the code below. I got this code off the web, so I dont understand all the parameters completely, but I do like the idea of just letting windows figure out the correct program association for whatever file I'm trying to manipulate.
I'm still pretty new when it comes to vba coding. I learn a lot with each new project, and I'm open to better ways of doing things.
I have working code here that I can use to open or print a pdf.
When I run the testPrint subroutine, the document prints. Problem is it prints with the default print settings on size 8.5x11 paper. The document I'm printing does not fit correctly on this size paper.
I have saved a print settings file "BP_11x17.sav" which is currently in the same directory as the pdf file (my desktop).
I need to know how to tell Acrobat Reader to use this .sav file for the print settings.
Can anyone tell me how to do this?
Please consider:
*The excel file containing this code will be executed from multiple users at multiple workstations.
*All have acrobat reader, although some may have different versions then others.
*Location of the Acrobat Reader exe may not always be in same directory.
*Location of the print settings (BP_11x17.sav) will always be in the same directory, and will be accessible by everyone.
*I have no control over how each users VBA reference library is setup.
These concerns are why I am using the code below. I got this code off the web, so I dont understand all the parameters completely, but I do like the idea of just letting windows figure out the correct program association for whatever file I'm trying to manipulate.
I'm still pretty new when it comes to vba coding. I learn a lot with each new project, and I'm open to better ways of doing things.
Code:
Option Explicit
Public Declare Function ShellExecute _
Lib "shell32.dll" Alias "ShellExecuteA" ( _
ByVal hwnd As Long, _
ByVal lpOperation As String, _
ByVal lpFile As String, _
ByVal lpParameters As String, _
ByVal lpDirectory As String, _
ByVal nShowCmd As Long) _
As Long
Public Function PrintThisDoc(formname As Long, FileName As String)
'On Error Resume Next
Dim X As Long
X = ShellExecute(formname, "Print", FileName, 0&, 0&, 3)
End Function
Public Function OpenThisDoc(formname As Long, FileName As String)
'On Error Resume Next
Dim X As Long
X = ShellExecute(formname, "Open", FileName, 0&, 0&, 3)
End Function
Sub testOpen()
Dim openThis
Dim strDir As String
Dim strFile As String
Dim strloc As String
strDir = "C:\Documents and Settings\MYNAME\Desktop"
strFile = "MYPRINT.pdf"
strloc = strDir & "\" & strFile
openThis = OpenThisDoc(0, strloc)
End Sub
Sub testPrint()
Dim printThis
Dim strDir As String
Dim strFile As String
Dim strloc As String
strDir = "C:\Documents and Settings\MYNAME\Desktop"
strFile = "MYPRINT.pdf"
strloc = strDir & "\" & strFile
printThis = PrintThisDoc(0, strloc)
End Sub