mrmmickle1
Well-known Member
- Joined
- May 11, 2012
- Messages
- 2,461
I am attempting to navigate to a webpage using IE. I have been successful at getting to the appropriate webpage. However, I would like to open a link within the webpage in the browser in another window(Which is an image). Copy the image then paste it back into excel. I have been successful at opening the webpage using a Userform. Here is the code for this first aspect:
The user input number for example:
If the user inputs the number 25423310 into the txtbox then it navigates to a certain webpage.
On this webpage and all other webpages where different #'s are used are very similar. The number (25423310) is always used to identify an image. However it has more characters. For example the image is always on line 30 of the HTML code. On this example the HTML code lists the image as:
<metaproperty="og:image" content="http://images.anthropologie.com/is/image/Anthropologie/25423310_065_b?$redesign-appcat$"/>
The number used in the txtbox to naviagete to the URL Ex: 25423310) is always within line 30 of code in HTML. Is it possible to run a query or parse this line of code and direct ie to open this image in a new window then copy and paste it based on the criteria of the user input? Ex. 25423310?
I found a few threads that have some code attempting to parse HTML data. Here is one that I feel could aid my cause. Is anyone able to help me solve this problem?
Any help with this problem would be much appreciated!!!
Rich (BB code):
Sub Anthro()
Application.ScreenUpdating = False
Set ie = CreateObject("InternetExplorer.Application")
With ie
.Visible = True
strURL = "http://www.anthropologie.com/anthro/product/shopnew-clothes/" & TextBox1.Value & ".jsp"
.navigate strURL
Application.ScreenUpdating = True
End With
End Sub
The user input number for example:
If the user inputs the number 25423310 into the txtbox then it navigates to a certain webpage.
On this webpage and all other webpages where different #'s are used are very similar. The number (25423310) is always used to identify an image. However it has more characters. For example the image is always on line 30 of the HTML code. On this example the HTML code lists the image as:
<metaproperty="og:image" content="http://images.anthropologie.com/is/image/Anthropologie/25423310_065_b?$redesign-appcat$"/>
The number used in the txtbox to naviagete to the URL Ex: 25423310) is always within line 30 of code in HTML. Is it possible to run a query or parse this line of code and direct ie to open this image in a new window then copy and paste it based on the criteria of the user input? Ex. 25423310?
I found a few threads that have some code attempting to parse HTML data. Here is one that I feel could aid my cause. Is anyone able to help me solve this problem?
Rich (BB code):
Sub PropInfo()
Dim appIE As SHDocVw.InternetExplorer
Set appIE = New SHDocVw.InternetExplorer
Dim varTables, varTable
Dim varRows, varRow
Dim varCells, varCell
Dim lngRow As Long, lngColumn As Long
Dim txt As String
'OPEN INTERNET EXPLORER, GO TO WEBPAGE
appIE.Visible = True
appIE.navigate "http://gisims2.miamidade.gov/MyHome/proptext.asp"
Do While appIE.Busy: DoEvents: Loop
Do While appIE.readyState <> 4: DoEvents: Loop
'POPULATE USER FIELDS, AND PERFORM A QUERY
With appIE.document.frmNavigation
.Item("bytool").Value = "ADDR" 'Search by' dropdown
.Item("bytool").onchange
.Item("stnum").Value = "2417" 'house #' field
.Item("stdir").Value = ""
.Item("stname").Value = "ponce de leon" 'street name' field
.Item("sttype").Value = "BLVD" 'street type' field
.submit
End With
Do While appIE.Busy: DoEvents: Loop
Do While appIE.readyState <> 4: DoEvents: Loop
appIE.document.all.Item
Call appIE.document.parentWindow.execScript("doAddrSearch()", "Javascript")
Do While appIE.Busy: DoEvents: Loop
Do While appIE.readyState <> 4: DoEvents: Loop
'SCRAPE WEBPAGE FOR INFO
For i = 0 To appIE.document.getElementsByTagName("TD").Length - 1
Set s = appIE.document.getElementsByTagName("TD").Item(i)
txt = s.getAttribute("innerText")
If txt <> "" Then
If InStr(1, txt, "CLUC") > 0 Then
Worksheets("Sheet1").Range("DropOff").Value = txt
Exit For
End If
End If
Next
Set s = Nothing
End Sub
Any help with this problem would be much appreciated!!!
Last edited: