I am having trouble figuring out why the Internet Explorer windows are visible even though I set .Visible = False, and why they don't close with IE.Quit and Set IE = Nothing.
I want to pull tracking numbers and scrape USPS by concatenating them onto the URL. The links work but the Internet Explorer Windows are visible and they don't close.
Dim newSheet As Worksheet
Set newSheet = Sheets.Add
Worksheets("AAASWOSPOLevel_crosstab").Activate
Dim i As Integer
Dim usps As Integer
Dim ups As Integer
Dim fedex As Integer
Dim dhl As Integer
Dim ontrac As Integer
i = 2
usps = 2
ups = 2
fedex = 2
dhl = 2
ontrac = 2
newSheet.Cells(i - 1, 1) = "USPS"
newSheet.Cells(i - 1, 3) = "UPS"
newSheet.Cells(i - 1, 5) = "FedEx"
newSheet.Cells(i - 1, 7) = "DHL"
newSheet.Cells(i - 1, 9) = "OnTrac"
newSheet.Activate
newSheet.Range("A:P").NumberFormat = "@"
While Not IsEmpty(Worksheets("AAASWOSPOLevel_crosstab").Cells(i, 15).Value)
If Worksheets("AAASWOSPOLevel_crosstab").Cells(i, 15).Value = "USPS" Then
newSheet.Cells(usps, 1) = Replace(Worksheets("AAASWOSPOLevel_crosstab").Cells(i, 13), """", "")
Dim IE As Object
Set IE = GetObject("new:{D5E8041D-920F-45e9-B8FB-B1DEB82C6E5E}")
With IE
.Navigate "https://tools.usps.com/go/TrackConfirmAction?tLabels=" & Replace(Worksheets("AAASWOSPOLevel_crosstab").Cells(i, 13), """", "")
.Visible = False
End With
While IE.ReadyState <> READYSTATE_COMPLETE
DoEvents
Wend
IE.Quit
Set IE = Nothing
usps = usps + 1
If usps = 7 Then Exit Sub
End If
Wend