Can someone please help. Ive spent hours trying to figure this out. I have a VBA macro that opens up a website and copies a table to excel. However, before it copies the table, I need to change a drop down box selection from "10" to "100" to show all lines in the table. Here is the VBA code:
>>> use code - tags <<<
>>> use code - tags <<<
Code:
Sub GetTable()
Dim ieApp As InternetExplorer
Dim ieDoc As Object
Dim ieTable As Object
Dim clip As DataObject
'create a new instance of ie
Set ieApp = New InternetExplorer
'you don’t need this, but it’s good for debugging
ieApp.Visible = True
'assume we’re not logged in and just go directly to the login page
ieApp.Navigate "http://"
Do While ieApp.Busy: DoEvents: Loop
Do Until ieApp.ReadyState = READYSTATE_COMPLETE: DoEvents: Loop
Set ieDoc = ieApp.Document
'fill in the login form – View Source from your browser to get the control names
With ieDoc.forms(0)
.DriverNo.Value = "Driver No"
.Pin.Value = "Pin"
.submit
End With
Do While ieApp.Busy: DoEvents: Loop
Do Until ieApp.ReadyState = READYSTATE_COMPLETE: DoEvents: Loop
'now that we’re in, go to the page we want
ieApp.Navigate "http://"
Do While ieApp.Busy: DoEvents: Loop
Do Until ieApp.ReadyState = READYSTATE_COMPLETE: DoEvents: Loop
'get the table based on the table’s id
Set ieDoc = ieApp.Document
Set ieTable = ieDoc.all.Item("taoutheader")
'copy the tables html to the clipboard and paste to the sheet
If Not ieTable Is Nothing Then
Set clip = New DataObject
clip.SetText "" & ieTable.outerHTML & ""
clip.PutInClipboard
Sheet12.Visible = xlSheetVisible
Sheet12.Cells.Clear
Sheet12.Select
Sheet12.Range("A2").Select
Sheet12.PasteSpecial "Unicode Text"
Sheet12.Visible = xlSheetHidden
End If
'close ‘er up
ieApp.Quit
Set ieApp = Nothing
End Sub
Last edited by a moderator: