次のコードを使用して Excel シートを Windows フォームの WebBrowser コントロールにロードしています。Navigated の msgbox は起動しますが、シートは WebBrowser に表示されません。また、Navigated2 は役に立ちません。足りないものはありますか?
参考: プロジェクトへの次の参照が宣言されています。
Microsoft Office 14.0 Object Library
Microsoft Excel 14.0 Object Library
Microsoft Internet Controls
Microsoft Common Dialog Control 6.0 (SP6)
Imports Office = Microsoft.Office.Core
Imports Excel = Microsoft.Office.Interop.Excel
Public Class Form1
Dim oDocument As Object
Private xlAPP As New Excel.Application
Private xlWBook As Excel.Workbook
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
' Create new Application.
Dim filename As String = Nothing
With OpenFileDialog1
.CheckFileExists = True
.ShowReadOnly = True
.Filter = "Excel files *.xlsx|*.xlsx"
If .ShowDialog = Windows.Forms.DialogResult.OK Then
'Load file
filename = .FileName
End If
End With
With xlAPP
.Visible = False
xlWBook = .Workbooks.Open(filename)
xlWBook.Activate()
End With
Me.WebBrowser1.Navigate(xlWBook.FullName)
End Sub
Private Sub WebBrowser1_Navigated(ByVal pDisp As Object, URL As Object) Handles WebBrowser1.Navigated
MsgBox("NavigateComplete Event")
On Error Resume Next
oDocument = pDisp.Document
End Sub
Private Sub WebBrowser1_DocumentCompleted(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
With xlAPP.CommandBars("Standard")
.Visible = True
End With
End Sub
End Class