I get this message too:
dialogArguments.__IE_Print
res://C:\\WINDOWS\System32
Main Topics
Browse All TopicsHello Friends,
I use the following code to print HTML files using the SHDOCVW.DLL:
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:\Test.html"
iSHDocIE.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUS
It worked fine the first time (I sent it to a network printer and it printed without any errors). Now I get the following error:
Run-time error -2147221248
Method 'ExecWB' of object 'IWebBrowser2' failed
And when I click Debug and then continue, it prints. But I don't want this user interaction.
Can anyone tell me what is wrong with this code? A similar code in VB.Net always works like a charm for me.
Regards,
Srinivas
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Finally I get this working as:
Dim WithEvents iSHDocIE As SHDocVw.InternetExplorer
Dim WithEvents iSHDocWebBrowser As SHDocVw.WebBrowser
Private Sub Command1_Click()
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"
End Sub
Private Sub iSHDocIE_NavigateComplete2
Retry:
If (iSHDocIE.QueryStatusWB(OL
Debug.Print "YES"
Debug.Print iSHDocIE.QueryStatusWB(OLE
iSHDocIE.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUS
Else
Debug.Print "NO"
Debug.Print iSHDocIE.QueryStatusWB(OLE
GoTo Retry
End If
End Sub
But when I use the same code to make a DLL and reference it somewhere else, i get this error:
dialogArguments.__IE_Print
This is getting me crazy... does anyone have any better ideas than this code??? something actually working????
As far as I know, many of the WebBrowser's controls are disabled if the .Visible is set to false. MS did this (IMHO) to protect the end user from sneaky developers.
Instead of setting .Visible to false, try hiding it some other way. You could move the control out of the visible area your form, or place it in a container that is obscured by another container.
Hope this helps,
-- ScribbleMeat
I use webbrowser control instead and this works for me
Option Explicit
Private Sub Form_Load()
Timer1.Interval = 1
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
Timer1.Enabled = False
WebBrowser1.Navigate Command
End Sub
Private Sub Timer2_Timer()
Timer2.Enabled = False
End
End Sub
Private Sub WebBrowser1_DocumentComple
Debug.Print pDisp
If (pDisp = WebBrowser1) Then
WebBrowser1.ExecWB 6, 2, 0, 0
Timer2.Interval = 3000
Timer2.Enabled = True
End If
End Sub
Hello EddyKT,
As suggested by you, I tried with the following code:
Dim WithEvents iSHDocWB As SHDocVw.WebBrowser
Private Sub Command1_Click()
Set iSHDocWB = New SHDocVw.WebBrowser
iSHDocWB.Navigate "C:\Documents and Settings\PN07934\Desktop\T
End Sub
Private Sub iSHDocWB_DocumentComplete(
iSHDocWB.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUS
End Sub
But the error props up saying:
Run-time error '-2147477259 (80004005)'
Automation error
Unspecified error
Any ideas???
That doesn't work either, but this works:
Dim WithEvents iSHDocWB As SHDocVw.WebBrowser
Dim WithEvents iSHDocIE As SHDocVw.InternetExplorer
Private Sub Command1_Click()
Set iSHDocIE = New SHDocVw.InternetExplorer
Set iSHDocWB = iSHDocIE
iSHDocWB.Navigate "C:\Documents and Settings\PN07934\Desktop\T
End Sub
Private Sub iSHDocWB_DocumentComplete(
If (pDisp = iSHDocWB) Then
iSHDocWB.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUS
End If
End Sub
Again, if I develop an Activex DLL as:
Dim WithEvents iSHDocIE As SHDocVw.InternetExplorer
Dim WithEvents iSHDocWB As SHDocVw.WebBrowser
Public Function PrintPDF(FileName As String) As Integer
Set iSHDocIE = New SHDocVw.InternetExplorer
Set iSHDocWB = iSHDocIE
iSHDocWB.Navigate FileName
End Function
Private Sub iSHDocIE_DocumentComplete(
iSHDocWB.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUS
End Sub
And use it as:
Private Sub Command1_Click()
Dim pdfW As PDFWriter.PDFWriterClass
Set pdfW = New PDFWriterClass
pdfW.PrintPDF ("C:\Documents and Settings\PN07934\Desktop\T
End Sub
I get the "dialogArguments.__IE_Prin
Any ideas???
I finally used this:
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As
Long)
Public Sub PrintPDF(fileName As String)
Set ieObj = CreateObject("InternetExpl
ieObj.Visible = True
ieObj.Navigate fileName
ieObj.ExecWB 6, 2
Sleep 1000
ieObj.Quit
Set ieObj = Nothing
End Sub
This worked even after being compiled into a DLL.
Thanks guys for your replies... they were very helpful and guiding...
Business Accounts
Answer for Membership
by: srinivas_vemlaPosted on 2005-04-25 at 20:04:42ID: 13863767
I have changed my code to the following:
ECMDID_PRI NT) <> 0) Then CMDID_PRIN T) ER CMDID_PRIN T)
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(OL
Debug.Print "YES"
Debug.Print iSHDocIE.QueryStatusWB(OLE
iSHDocIE.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUS
Else
Debug.Print "NO"
Debug.Print iSHDocIE.QueryStatusWB(OLE
GoTo Retry
End If
But not much result. I was thinking that if the file is loaded, then it should be able to be printed. But it prints only if I put a break point somewhere in the code and step thru... If I just let it run, it does nothing.
Any suggestions plssss...
Thanks,
Srinivas