Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21281

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

$
0
0
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.

Viewing all articles
Browse latest Browse all 21281

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>