Skip to content

Instantly share code, notes, and snippets.

@jakelosh
Last active October 4, 2023 19:45
Show Gist options
  • Save jakelosh/533f8fe520950769b0f2 to your computer and use it in GitHub Desktop.
Save jakelosh/533f8fe520950769b0f2 to your computer and use it in GitHub Desktop.
As part of a larger process I was trying to automate, I had to interact with a web browser. Interacting with Internet Explorer from Excel VBA is pretty simple and there are a lot of good explanations out there, but I thought I'd share a snippet of code that selects everything on the webpage and pastes it to an output sheet for further processing…
Public Sub NavigateIe()
'Declare some helpful variables
Dim wksIn As Worksheet, wksOut As Worksheet
Dim strTickerArr() As String, varNotionalArr() As Variant, strBloomArr() As String
Dim strLink As String
'Set some worksheet names
Set wksIn = ThisWorkbook.Worksheets("INPUT")
Set wksOut = ThisWorkbook.Worksheets("OUTPUT")
Set wksLookUp = ThisWorkbook.Worksheets("Look Up Table")
'Now we'll load the URL into IE and pull the data
Dim objIe As Object
Set objIe = CreateObject("InternetExplorer.Application")
With objIe
.Visible = True
.Navigate strLink
Do Until .ReadyState = 4: DoEvents: Loop
.ExecWB 17, 0 'SelectAll
.ExecWB 12, 2 'Copy
End With
wksOut.PasteSpecial Format:="Text", link:=False, DisplayAsIcon:=False
End Sub
@ricardo-bi
Copy link

hola si pero los id no me los trae

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment