Hello Friends,
I use the following code to print HTML files using the SHDOCVW.DLL (By adding a reference to it):
Dim iSHDocIE As SHDocVw.InternetExplorer
Dim iSHDocWebBrowser As SHDocVw.WebBrowser
Set iSHDocIE = New SHDocVw.InternetExplorer
Set iSHDocWebBrowser = New SHDocVw.WebBrowser
Set iSHDocWebBrowser = iSHDocIE
iSHDocWebBrowser.Visible = False 'to enable background printing
iSHDocIE.Navigate "C:\Temp.htm"
Retry:
If (iSHDocIE.QueryStatusWB(OLECMDID_PRINT) <> 0) Then
Debug.Print "YES"
Debug.Print iSHDocIE.QueryStatusWB(OLECMDID_PRINT)
iSHDocIE.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER
Else
Debug.Print "NO"
Debug.Print iSHDocIE.QueryStatusWB(OLECMDID_PRINT)
GoTo Retry
End If
It works great if I set a breakpoint somewhere at or above "Navigate" line and step through. But if I just let this code run, it gives an error saying:
dialogArguments.__IE_PrintType is null or not an object
res://C:\\WINDOWS\System32\shdoclc.dll/preview.dlg
and does not print anything. I have no idea why this is happening. Please let me know if you guys have any suggestions.
Thanks
I use the following code to print HTML files using the SHDOCVW.DLL (By adding a reference to it):
Dim iSHDocIE As SHDocVw.InternetExplorer
Dim iSHDocWebBrowser As SHDocVw.WebBrowser
Set iSHDocIE = New SHDocVw.InternetExplorer
Set iSHDocWebBrowser = New SHDocVw.WebBrowser
Set iSHDocWebBrowser = iSHDocIE
iSHDocWebBrowser.Visible = False 'to enable background printing
iSHDocIE.Navigate "C:\Temp.htm"
Retry:
If (iSHDocIE.QueryStatusWB(OLECMDID_PRINT) <> 0) Then
Debug.Print "YES"
Debug.Print iSHDocIE.QueryStatusWB(OLECMDID_PRINT)
iSHDocIE.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER
Else
Debug.Print "NO"
Debug.Print iSHDocIE.QueryStatusWB(OLECMDID_PRINT)
GoTo Retry
End If
It works great if I set a breakpoint somewhere at or above "Navigate" line and step through. But if I just let this code run, it gives an error saying:
dialogArguments.__IE_PrintType is null or not an object
res://C:\\WINDOWS\System32\shdoclc.dll/preview.dlg
and does not print anything. I have no idea why this is happening. Please let me know if you guys have any suggestions.
Thanks