dodonohoe
01-03-2013, 04:38 AM
Hi all,
I have the following code that opens a PDF document and prints the entire document. I was wondering if it's possible to print a named range such as pages 1-2 & 4-7?
Private 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
Const SW_HIDE As Long = 0&
Const SW_SHOW As Long = 5&
Sub PrintFile(strFilePath As String)
ShellExecute Application.hWnd, "Print", strFilePath, 0&, 0&, SW_HIDE
End Sub
Sub OpenFile(strFilePath As String)
ShellExecute Application.hWnd, "Open", strFilePath, 0&, 0&, SW_SHOW
End Sub
Sub PrintPDFsInputBox()
Dim Month As String
Dim sFile As String
Dim sFolder As String
Month = Application.Inputbox("Please enter the reporting month")
sFolder = "C:\"
sFile = Dir(sFolder & Month & "\saf*.pdf")
Do While sFile <> ""
PrintFile sFolder & sFile
sFile = Dir
Loop
End Sub
Many thanks,
Des
I have the following code that opens a PDF document and prints the entire document. I was wondering if it's possible to print a named range such as pages 1-2 & 4-7?
Private 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
Const SW_HIDE As Long = 0&
Const SW_SHOW As Long = 5&
Sub PrintFile(strFilePath As String)
ShellExecute Application.hWnd, "Print", strFilePath, 0&, 0&, SW_HIDE
End Sub
Sub OpenFile(strFilePath As String)
ShellExecute Application.hWnd, "Open", strFilePath, 0&, 0&, SW_SHOW
End Sub
Sub PrintPDFsInputBox()
Dim Month As String
Dim sFile As String
Dim sFolder As String
Month = Application.Inputbox("Please enter the reporting month")
sFolder = "C:\"
sFile = Dir(sFolder & Month & "\saf*.pdf")
Do While sFile <> ""
PrintFile sFolder & sFile
sFile = Dir
Loop
End Sub
Many thanks,
Des