Public Class Form2
Dim oDocument As Object
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Button1.Text = "Browse"
With OpenFileDialog1
.Filter = "Office Documents " & _
"(*.doc, *.xls, *.ppt)|*.doc;*.xls;*.ppt"
.FilterIndex = 1
End With
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Dim strFileName As String
'Find the Office document.
With OpenFileDialog1
.FileName = ""
.ShowDialog()
strFileName = .FileName
End With
'If the user does not cancel, open the document.
If strFileName.Length Then
oDocument = Nothing
AxWebBrowser1.Navigate(strFileName)
End If
End Sub
Private Sub Form2_Closing(ByVal sender As Object, ByVal e As _
System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
oDocument = Nothing
End Sub
Private Sub AxWebBrowser1_NavigateComplete2(ByVal sender As Object, _
ByVal e As AxSHDocVw.DWebBrowserEvents2_NavigateComplete2Event) _
Handles AxWebBrowser1.NavigateComplete2
On Error Resume Next
oDocument = e.pDisp.Document
'Note: You can use the reference to the document object to
' automate the document server.
MsgBox("File opened by: " & oDocument.Application.Name)
End Sub
End Class
-------------------------------------------------------------------------------------------------------------------------
I tryied to open a Doc file in WebBrowser Control using VB.Net but its only shows me a dilog box which content Open, Save and cancel button but content in doc file naver display in webBrowser