Hiding MS Word GUI using WebBrowser (ieframe.dll) control RRS feed

  • Question

  • I'm working on an application where we need to display read-only MS Office documents in a window much like the preview pane in Windows Explorer.

     Currently, my solution is to use the WebBrowser ActiveX control (ieframe.dll) along with setting certain registry keys so that IE renders Office documents in an embedded manner. So far so good. I'm able to get Word, PowerPoint, Excel and Word documents to appear nicely (see code snippet below) and function almost (see below) like I want.

     The first and most annoying issue I have at the moment is that the toolbar ribbon in Word always appears no matter what "visible" settings I use for toolbars and ribbons. All other Office documents render as desired - without any GUI components visible. What's more annoying is that in the extern standalone IE browser this does NOT occur. In the IE browser I can open any Word document and it is displays nicely centered and sized without ANY GUI components. This is EXACTLY what I would like to reproduce using the WebBrowser control in my VB 6 app. Here is the rendering code I'm using (I leave all the commented lines in so you can see all that I have tried):

        Sub OpenDocument(ByVal strURL As String)
           htmlPreview.FullScreen = False
           htmlPreview.AddressBar = False
           htmlPreview.MenuBar = False
           htmlPreview.StatusBar = False
           htmlPreview.ToolBar = 0
           htmlPreview.Top = Height + 100
           htmlPreview.Navigate2 strURL
        End Sub

        Private Sub htmlPreview_DocumentComplete(ByVal pDisp As Object, URL As Variant)
           ' On Error Resume Next
           Set objDocument = htmlPreview.Document

           If InStr(URL, ".doc") > 0 Then

              ' Dim i
              ' For i = 1 To 10 'objDocument.Application.CommandBars.Count
                 ' Debug.Print i, objDocument.Application.CommandBars(i).Name
                 ' objDocument.Application.CommandBars(i).Visible = False
              ' Next
              ' objDocument.Application.CustomizationContext = objDocument.Application.ActiveDocument.AttachedTemplate
              ' objDocument.Application.CommandBars("Ribbon").Visible = False
              ' objDocument.Application.ActiveProtectedViewWindow.ToggleRibbon
              ' objDocument.Application.CommandBars("Standard").Visible = False
              ' objDocument.Application.CommandBars("Task Pane").Visible = False
              ' objDocument.Application.CommandBars("Status Bar").Visible = False
              ' objDocument.Application.CommandBars("System").Visible = False
              objDocument.Application.ActiveDocument.Protect 3
              objDocument.Application.PrintPreview = True
              objDocument.Application.ActiveWindow.View.Zoom.PageFit = 2
           End If

           htmlPreview.Top = 0 'now that the document has rendered move the WebBrowser control into place - this has the effect of a much cleaner rendering
        End Sub

     The second most pressing issue is the somehow distinguish between clicks on document hyperlinks and normal regions. We would like a click event to close the preview except when it is on a hyperlink. Then we want it function normally and navigate to the link address.

     Any and all help appreciated.

    Monday, September 16, 2013 8:55 PM

All replies

  • Hi,

    Thank you for posting in the MSDN Forum.

    I'm trying to involve some senior engineers into this issue and it will take some time. Your patience will be greatly appreciated.

    Sorry for any inconvenience and have a nice day!

    Best regards,


    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Wednesday, September 18, 2013 7:38 AM
  • I don't mean to be flip, but how many weeks are there in "some time"?

    Is anybody going to help with this issue really? It must not be that big a deal since the standalone IE browser does it without any issue.

    Sunday, October 6, 2013 5:26 AM