How to get a webpage data without navigating to it. VBA

I came across a technique a few years back that allowed me to grab data from a webpage without navigating to that page. I was actually very simple, but I forgot how to did it.
I believe it was just the Excel internet or html libraries, but it may have been one of windows APIs.

I "think" it was something like a "get" command.

I have about 4000 pages I need to verify nightly and would really like to speed things up.

I did this in Widows 7 and probably IE9. I currently run Win 10 with Edge. Have not done much webstuff with Edge.

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jon von der HeydenCourse Leader & Managing DirectorCommented:
Hi Bruce

I don't know what URL you want to get from and what you want to actually get.  However this exhibit shows you how to use WinHTTP (late bound - so no reference checking required).  And it is not browser specific.

Sub Example()
    Debug.Print GetSource("")
End Sub

Function GetSource(ByVal strURL As String) As String
    Dim objWinHttp As Object 'WinHttpRequest
    Set objWinHttp = CreateObject("WinHttp.WinHttpRequest.5.1")

    Call objWinHttp.Open("GET", strURL)
    Call objWinHttp.Send
    GetSource = objWinHttp.ResponseText
End Function

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
BrujAuthor Commented:
Thank you VERY VERY much! Works like a charm and will same me hours of computer running each day!
Now I just need to re-write my parsing functions!
I am really surprised this method is not used more! It is so much cleaner, faster and easier!
I was really floored when I came across it the first time, and was using it on alot of code (but that was a few years back!)
I just have not don't that type of web automation for a long time.

Very complete and was there right at the right time (think it was less than 15 min!)
Jon von der HeydenCourse Leader & Managing DirectorCommented:
You're most welcome Bruce.  As the saying goes, "there's more than one way to skin a cat".  I only elected to use WinHTTP out of familiarity.  Best of luck!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.