Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. printing xml in ie

printing xml in ie

Scheduled Pinned Locked Moved Visual Basic
xmlcomhelpquestion
7 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Stephen Lintott
    wrote on last edited by
    #1

    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)

    D 1 Reply Last reply
    0
    • S Stephen Lintott

      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)

      D Offline
      D Offline
      Duncan Edwards Jones
      wrote on last edited by
      #2

      Any detail in the COM exception? What is in the filename variable?

      '--8<------------------------ Ex Datis: Duncan Jones Merrion Computing Ltd

      S 1 Reply Last reply
      0
      • D Duncan Edwards Jones

        Any detail in the COM exception? What is in the filename variable?

        '--8<------------------------ Ex Datis: Duncan Jones Merrion Computing Ltd

        S Offline
        S Offline
        Stephen Lintott
        wrote on last edited by
        #3

        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)

        D 1 Reply Last reply
        0
        • S Stephen Lintott

          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)

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          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

          S 2 Replies Last reply
          0
          • D Dave Kreskowiak

            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

            S Offline
            S Offline
            Stephen Lintott
            wrote on last edited by
            #5

            Hi 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)

            1 Reply Last reply
            0
            • D Dave Kreskowiak

              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

              S Offline
              S Offline
              Stephen Lintott
              wrote on last edited by
              #6

              Before I forget. This error only happens when you print out multiple documents

              Stephen Lintott Bsc IT (RAU)

              S 1 Reply Last reply
              0
              • S Stephen Lintott

                Before I forget. This error only happens when you print out multiple documents

                Stephen Lintott Bsc IT (RAU)

                S Offline
                S Offline
                Stephen Lintott
                wrote on last edited by
                #7

                just for the sake of completeness I found the following sollution at http://edn.embarcadero.com/article/27043[^]

                Stephen Lintott Bsc IT (RAU)

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups