messer5740
New Member
- Joined
- Aug 13, 2020
- Messages
- 2
- Office Version
- 2013
- Platform
- Windows
Hi all,
I am looking to make a program which I can web scrape HTML src's with. My code enters info into a couple text boxes and runs an external query to generate graphs. I want to take the graph src, download it, and insert it into my excel doc. I am having a hell of a time getting the src scraped however. Think you can give me a hand?
Here is my code:
I know it really needs cleaned up, but I need to make it work first.
I am looking to make a program which I can web scrape HTML src's with. My code enters info into a couple text boxes and runs an external query to generate graphs. I want to take the graph src, download it, and insert it into my excel doc. I am having a hell of a time getting the src scraped however. Think you can give me a hand?
Here is my code:
VBA Code:
Private Declare PtrSafe Function URLDownloadToFile Lib "urlmon" _
Alias "URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, _
ByVal szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long
Sub openScrubLineLossCharts()
Dim ie As Object
Dim dateToday As Date
Dim userElement As Variant
Dim imgsrc As Object
Dim dlpath As Variant
Dim previewImg As Variant
Dim URL As String
Dim html As HTMLDocument
Dim ElementCol As Object
Dim Link As Object
Dim ecol As Long
Dim objElement As IHTMLElement
URL = "http://botprodweb/LineLossReview/"
Set ie = CreateObject("internetexplorer.application") 'internet explorer
'ensures website is properly loaded
With ie
ie.Visible = True '78687968796867876878976876True when testing, False when active. Allows view of changes made to website
ie.Navigate "http://botprodweb/LineLossReview/default.aspx" 'Line loss query website
Do While .Busy
DoEvents
Loop
Do While .ReadyState <> 4
DoEvents
Loop
End With
'
' etc
'
'
' BELOW IS WHERE I NEED HELP AT!
Dim doc As HTMLDocument
Set doc = ie.Document
Dim sDD As String
sDD = doc.getElementsByTagName("img")(src)
'25 line loss chart
Dim ActiveDocument As Object
Set ActiveDocument = ie
'Set objElement = ActiveDocument.all.tags("head").Item(0)
Dim intCount As Integer
'For Each objElement In ActiveDocument.body.all
intCount = intCount + 1
objElement.ID = objElement.tagName & intCount
'Next
dlpath = "J:\BP&S_Operations\Daily Multi-Tool\Line Loss Chart Photo Dump\"
URLDownloadToFile 0, src, dlpath & "25.png", 0, 0
End Sub
I know it really needs cleaned up, but I need to make it work first.