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
Sub testPrint()
Dim printThis
Dim strDir As String
Dim strFile As String
strDir = "C:\Users\Hello Baby\Desktop"
strFile = "abc.pdf"
printThis = PrintThisDoc(0, strDir & "\" & strFile)
End Sub
@webmax
Hi
Please try the below code in the normal module
`
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 Sub testPrint() Dim printThis Dim strDir As String Dim strFile As String strDir = "C:\Users\Hello Baby\Desktop" strFile = "abc.pdf" printThis = PrintThisDoc(0, strDir & "\" & strFile) End Sub
`
Hope it is solve your problem other wise please inform us
Thanks
Patnaik
Dim printThis
Dim strDir As String
Dim strFile As String
strDir = "E:\SignOnForms-Data\FormsMisc"
strFile = "XXXXX.pdf"
printThis = PrintThisDoc(0, strDir & "\" & strFile)
End Sub
Hi sgmPatnaik - It works fine. Thank you.
adding to that, I need to print different pdf pages. Say example if I put
1-2
5-6
9-10
13-14
17-18
21-22
25-26
........
........
in excel cell, it should print accordingly. Please help...