How to Automate finding websites in VBA

Brayheart

New Member
Joined
Nov 17, 2015
Messages
3
I have an excel spreadsheet of about 12,000 rows of data. I'm trying to automate the task as follows:

  • Step 1: Copy row 2 column C
  • Step 2: Paste and enter into google
  • Step 3: Select first link
  • Step 4: Copy webpage URl
  • Step 5: Paste URL to Row 2 Column K
  • Step 6: Repeat for next row
I'm fairly new to VBA and am not too sure on how to get it to interact with a Webdriver. Any guidance would be appreciated.
 
I was able to find the following code from another forum post that has VBA interact with Internet Explorer. I was wondering if someone might be able to help me edit it to do what I'm trying to do.



Rich (BB code):
Option Explicit
 
Sub GoToWebSiteAndPlayAroundNew()
Dim appIE As Object    ' InternetExplorer
Dim doc As Object    'HTMLDocument
Dim URL As String
Dim objIMG As Object    ' HTMLImg
Dim objAnchor As Object    ' HTMLAnchorElement
 
    Set appIE = CreateObject("InternetExplorer.Application")
 
    URL = "https://efolio.morgankeegan.com/escr....asp?errCode=2"
 
    With appIE
        .navigate URL
        .Visible = True
 
        Do While .busy: DoEvents: Loop
        Do While .ReadyState <> 4: DoEvents: Loop
 
        Set doc = .Document
 
        doc.getelementbyid("fUserName").Value = "UserName"
 
        doc.getelementbyid("fPassword").Value = "Password"
 
        Set objIMG = doc.images("SubmitRus")
 
        Set objAnchor = objIMG.parentElement
 
        objAnchor.Click
 
        Do While .busy: DoEvents: Loop
        Do While .ReadyState <> 4: DoEvents: Loop
 
    End With
 
    Set appIE = Nothing
 
End Sub
 
Last edited:
Upvote 0
I actually found a better piece of code:


Code:
Sub IMDB_URL_Search()


    Dim movie As String
    Dim link As Hyperlink


    movie = "The Shawshank Redemption"


    Range("IV1").Select


    Set link = ActiveSheet.Hyperlinks.Add(Anchor:=Selection, Address:= _
        "http://www.imdb.com/find?s=all&q=" & Replace(movie, " ", "+") _
        , TextToDisplay:="Link")


    link.Follow NewWindow:=False, AddHistory:=True


    'link.address will be the URL for this web link
    MsgBox link.Address
End Sub
 
Upvote 0

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top