Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB 6.0 Internet Explorer Printing Error

Status
Not open for further replies.

nphani

Technical User
Feb 10, 2002
104
US
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 have changed the permissions and rebooted, as mentioned in the following URL:


But no change...

I never had any issues with IE (as those mentioned in the above hyperlink). Should I add any other user to that list also? I am relatively new to VB. Does VB run under some different user who needs access rights to the DCOM Security? No idea why the error comes up in VB Code when it doesn't come otherwise... and why does it not come when I run the code using a breakpoint????

Any ideas are highly appreciated...

Thanks
 
I finally get it running like this:

Dim WithEvents iSHDocIE As SHDocVw.InternetExplorer
Dim WithEvents iSHDocWebBrowser As SHDocVw.WebBrowser

Public Sub PrintPDF(FileName As String)
Set iSHDocIE = New SHDocVw.InternetExplorer
Set iSHDocWebBrowser = New SHDocVw.WebBrowser

Set iSHDocWebBrowser = iSHDocIE
iSHDocWebBrowser.Visible = False 'to enable background printing

iSHDocIE.Navigate FileName
End Sub

Private Sub iSHDocIE_NavigateComplete2(ByVal pDisp As Object, URL As Variant)
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
End Sub


But the same code, if I put in a DLL and run it, it gives the "dialogArguments.__IE_PrintType is null or not an object" error...

Does anyone have any other code snippet at least that works fine?... the objective is just to use Internet Explorer reference to print a HTML... there should not be any user interaction...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top