'How can I get the full source (HTML) of a web-page with vba?

I am trying to automate a work task using excel VBA. I can't seem to get all the source code. I created this simple code to test it.

dim IE as object
Dim S as String
Set IE = CreateObject ("InternetExplorer.application")
Call LocateOpeGSAPage (IE)
DIM htmlDoc as HTMLDocument
set htmldoc = IE.Document
s = htmldoc.body.innerHTML

It pulls some HTML code that is a few lines long from my company's webpage.

If it is helpful here is what happens if I try to get the source code manually: When I manually right click on the web page and then click "View Source" that data from my company's web page that I mentioned above is what pulls up in the source code window under a tab called "Default.aspx"

However, If I manually right click on the webpage a second time and click on "view source" then a new tab opens in the source code window titled "DesktopDefault{1}" and it displays all the source code that I need.

How can I get to that source code using VBA? Any guidance is much appreciated.



Solution 1:[1]

I was able to find the answer to my own question. I didn't really need to grab the HTML source code, so I decided to change my code to reference Selenium because my true goal was to be able to locate the elements. I then used "SwitchtoFrame" to call the frame that had the elements that I wanted to access. When I didn't use "SwitchtoFrame" I was getting a NoSuchElement error so switchtoframe was the true problem solver for me.

Dim ch As New Selenium.ChromeDriver
Dim Elements As Selenium.WebElements
Dim Element As Selenium.WebElement
Dim FindBy As New Selenium.By
Dim url As String
Application.ScreenUpdating = False


ch.Get "https://abak.abch.net/cge/", Raise:=False
ch.SwitchToFrame ("MainFrame")

ch.FindElementById("ctl04_txtUsername").SendKeys "adock"
ch.FindElementById("ctl04_txtPassword").SendKeys "B12G89#F"

ch.FindElementById("ctl04_btnLogin").ClickDouble}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Block Block