printing xml in ie
-
Hi. This is a repost to a question I posted yesterday without any luck. Maby today will bring better results so here goes... I'm busy with a app that needs to print xml rendered by xslt. Currently I am printing with internet explorer in the following manner
Dim internetExplorer As New SHDocVw.InternetExplorerClass() Dim webBrowser As SHDocVw.IWebBrowser2 = CType(internetExplorer, SHDocVw.IWebBrowser2) 'Make the web browser visible webBrowser.Visible = False 'Display empty page so we have something to manipulate. Dim noValue As Object = System.Reflection.Missing.Value webBrowser.Navigate("file://" + fileName, noValue, noValue, noValue, noValue) While webBrowser.Busy Threading.Thread.Sleep(500) End While 'Get access to the webbrowser's document. internetExplorer.ExecWB(SHDocVw.OLECMDID.OLECMDID_PRINT, SHDocVw.OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER, noValue, noValue) 'CType(internetExplorer.Document, mshtml.IHTMLDocument2).close() Marshal.ReleaseComObject(internetExplorer) Marshal.ReleaseComObject(webBrowser)
I need to find a different way to do this as the above code gives a com exception. Or I need a workaround for the above code. If anybody can help I would greatly appreaciate it. Stephen
Stephen Lintott Bsc IT (RAU)
-
Hi. This is a repost to a question I posted yesterday without any luck. Maby today will bring better results so here goes... I'm busy with a app that needs to print xml rendered by xslt. Currently I am printing with internet explorer in the following manner
Dim internetExplorer As New SHDocVw.InternetExplorerClass() Dim webBrowser As SHDocVw.IWebBrowser2 = CType(internetExplorer, SHDocVw.IWebBrowser2) 'Make the web browser visible webBrowser.Visible = False 'Display empty page so we have something to manipulate. Dim noValue As Object = System.Reflection.Missing.Value webBrowser.Navigate("file://" + fileName, noValue, noValue, noValue, noValue) While webBrowser.Busy Threading.Thread.Sleep(500) End While 'Get access to the webbrowser's document. internetExplorer.ExecWB(SHDocVw.OLECMDID.OLECMDID_PRINT, SHDocVw.OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER, noValue, noValue) 'CType(internetExplorer.Document, mshtml.IHTMLDocument2).close() Marshal.ReleaseComObject(internetExplorer) Marshal.ReleaseComObject(webBrowser)
I need to find a different way to do this as the above code gives a com exception. Or I need a workaround for the above code. If anybody can help I would greatly appreaciate it. Stephen
Stephen Lintott Bsc IT (RAU)
Any detail in the COM exception? What is in the filename variable?
'--8<------------------------ Ex Datis: Duncan Jones Merrion Computing Ltd
-
Any detail in the COM exception? What is in the filename variable?
'--8<------------------------ Ex Datis: Duncan Jones Merrion Computing Ltd
The com exception states that a unregistered drag and drop occured. The filename varible is just a path to the file to be opened.
Stephen Lintott Bsc IT (RAU)
-
The com exception states that a unregistered drag and drop occured. The filename varible is just a path to the file to be opened.
Stephen Lintott Bsc IT (RAU)
Odd. I can't get your code to fail. It works perfrectly for me every time. Does this error occur on your dev machine or on a client?? Which version of IE is installed?? Did you add a Reference to C:\Windows\System32\ShDocVw.dll in your project, or how did you get access to these classes?? What line does the COM Exception get thrown on??
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008 -
Odd. I can't get your code to fail. It works perfrectly for me every time. Does this error occur on your dev machine or on a client?? Which version of IE is installed?? Did you add a Reference to C:\Windows\System32\ShDocVw.dll in your project, or how did you get access to these classes?? What line does the COM Exception get thrown on??
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008Hi thanks for your quick response. Here is what you wanted to know. This works fine on my dev box but fails on our client box. IE 7 is installed on that box same as my dev box. I referenced the Microsoft.mshtml.dll to get to the classes. As far as I can tell it is a dotnet wrapper for the dll above. I have no idea what line the error is thrown on as I can't step through it on the client box
Stephen Lintott Bsc IT (RAU)
-
Odd. I can't get your code to fail. It works perfrectly for me every time. Does this error occur on your dev machine or on a client?? Which version of IE is installed?? Did you add a Reference to C:\Windows\System32\ShDocVw.dll in your project, or how did you get access to these classes?? What line does the COM Exception get thrown on??
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008Before I forget. This error only happens when you print out multiple documents
Stephen Lintott Bsc IT (RAU)
-
Before I forget. This error only happens when you print out multiple documents
Stephen Lintott Bsc IT (RAU)
just for the sake of completeness I found the following sollution at http://edn.embarcadero.com/article/27043[^]
Stephen Lintott Bsc IT (RAU)