新建個窗體,新增CommandButton、WebBrowser控制元件。CommandButton控制元件用程式碼:Sub Test()Dim i As Long
Dim URL As String
Dim MySheet As Object
Set MyBrowser = UserForm1.WebBrowser1
Set MySheet= Thisworkbook.Sheets(“測試”)
MySheet.Cells.NumberFormat = "@"
.Navigate URL
Do Until .ReadyState = 4
DoEvents
Loop
End With
新建個窗體,新增CommandButton、WebBrowser控制元件。CommandButton控制元件用程式碼:Sub Test()Dim i As Long
Dim URL As String
Dim MySheet As Object
Dim MyBrowser As ObjectSet MyBrowser = UserForm1.WebBrowser1
Set MySheet= Thisworkbook.Sheets(“測試”)
MySheet.Cells.NumberFormat = "@"
With MyBrowser For i=2 To MySheet.UsedRange.Rows.CountURL = MySheet.Cells(i, 1).Value.Navigate URL
Do Until .ReadyState = 4
DoEvents
Loop
MySheet.Cells(i, 2) = .Document.body.innerhtml Next iEnd With
Set MyBrowser = Nothing End Sub