1
我想使用Excel中的宏自動化Internet Explorer。
我可以用硬編碼的數據做到這一點。我想從另一張表中複製數據。將動態數據傳遞給Internet Explorer - 創建多個登錄
示例: - 我想在example.com網站中創建多個登錄,並在Sheet中複製用戶名。
我在Excel代碼: -
Sub Submit()
Set objIE = CreateObject("InternetExplorer.Application")
objIE.Top = 0
objIE.Left = 0
objIE.Width = 800
objIE.Height = 600
objIE.AddressBar = 0
objIE.StatusBar = 0
objIE.Toolbar = 0
objIE.Visible = True 'We will see the window navigation
objIE.Navigate ("http://example.com")
Do
DoEvents
Loop Until objIE.ReadyState = 4
pageSource = objIE.Document.body.Outerhtml
objIE.Document.GetElementByID("ctl00_ContentPlaceHolder1_txtUserName").Value = "xyz"
objIE.Document.GetElementByID("ctl00_ContentPlaceHolder1_txtPassword").Value = "123"
objIE.Document.GetElementByID("ctl00_ContentPlaceHolder1_btnSubmit1").Click
End Sub
數據在Excel
+------+---------------+
| User | Password |
+------+---------------+
| ABC | 123 |
| XYZ | 456 |
| XCZ | 777 |
+------+---------------+