Using Web Browser Object To Display OFFICE DOCUMENTS
To display an office file in Windows, you can do this using the web browser object in the toolbox. See sample code below I created to view a Bill of Lading document created in the shipping department. This application is used to view and/or manipulate these files. Once file is loaded-(NavigateComplete)
Then I set the current document and hide the toolbars, which is optional. You can control which toolbars are available to the users.
Private Sub frmViewBOL_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim strMyBOL As String = strBOL_FileDIR & strBillOfLading & ".doc"
If File.Exists(strMyBOL) Then
oDoc = Nothing
webViewBOL.Navigate(strMyBOL)
Me.Text = "View Bill of Lading " & strBillOfLading
Else
MsgBox("Bill of Lading Not On File", MsgBoxStyle.Critical, msgTimken)
Me.Close()
End If
End Sub
Private Sub webViewBOL_NavigateComplete2(ByVal sender As Object, ByVal e As AxSHDocVw.DWebBrowserEvents2_NavigateComplete2Event) Handles webViewBOL.NavigateComplete2
oDoc = e.pDisp.document
webViewBOL.ExecWB(SHDocVw.OLECMDID.OLECMDID_HIDETOOLBARS, SHDocVw.OLECMDEXECOPT.OLECMDEXECOPT_DODEFAULT)
End Sub