Hi,
I have 2 macros, and need to use the IE object in the second macro that is declared and set in the first.
How do I set that up?
I have 2 macros, and need to use the IE object in the second macro that is declared and set in the first.
How do I set that up?
Code:
Sub UpdateOwensCards()
Dim IE As New SHDocVw.InternetExplorer
Dim IE As New SHDocVw.InternetExplorer
Dim HTMLdoc As MSHTml.HTMLDocument
Dim othwb As Variant
Dim objShellWindows As New SHDocVw.ShellWindows
Dim rownum As Long
Dim colnum As Long
rownum = 1
Do Until Sheets("Schedules").Cells(rownum, 1).Value = ""
schedID = Sheets("Schedules").Cells(rownum, 1).Value
Set IE = GetObject("new:{D5E8041D-920F-45e9-B8FB-B1DEB82C6E5E}")
With IE
.Visible = True
.Navigate "http://maintrakau/Domestic/"
While .Busy Or .ReadyState <> 4: DoEvents: Wend
End With
With IE
.Visible = True
.Navigate "http://maintrakau/OnForward/Business/customer_rates.asp?txtScheduleID=" & schedID & "&txtAction=R"
While .Busy Or .ReadyState <> 4: DoEvents: Wend
Set HTMLdoc = IE.Document
ProcessHTMLPage HTMLdoc
.Quit
End With
rownum = rownum + 1
Loop
End Sub
Sub ProcessHTMLPage(HTMLPage As MSHTml.HTMLDocument)
Dim HTMLTable As MSHTml.IHTMLElement
Dim HTMLTables As MSHTml.IHTMLElementCollection
Dim HTMLInput As MSHTml.IHTMLElement
Dim NewCharge As Long
Dim NewFeeName As String
Dim foundinput As Long
NewCharge = Sheets("Fees").Range("B2").Value
NewFeeName = Sheets("Fees").Range("A2").Value
Set HTMLTables = HTMLPage.getElementsByTagName("table")
For Each HTMLTable In HTMLTables
If HTMLTable.ID = "tblAdditionalCharges" Then
For Each HTMLInput In HTMLTable.getElementsByTagName("input")
If foundinput = 1 Then
Debug.Print HTMLInput.Value
Debug.Print NewCharge
'HTMLRow.Value = NewCharge
'Set Savebtn = IE.Document.getElementById("btnSave")
'Savebtn.click
'Application.wait (Now + TimeValue("00:00:01"))
foundinput = 0
End If
If HTMLInput.Value Like NewFeeName Then
foundinput = 1
End If
Next HTMLInput
End If
Next HTMLTable
End Sub