Web Query that imports url's as plain text

klatlap

Well-known Member
Joined
Sep 1, 2004
Messages
607
Office Version
  1. 2013
Platform
  1. Windows
Hi all, just wondering is there a way i can use my current web query to import url's as an address, currently i import it as full html then i have a function that turns the hyperlink in to plain text address, here is the codes i use for my queries.

The bottom query imports data nice and fast, but as plain text, if i try to use it on pagers where i want to use the urls on the page it just imports data that is displayed not the url address.

Rich (BB code):
Public Function ExecuteWebRequest(url As String) As String
    Dim oXHTTP As Object
    Set oXHTTP = CreateObject("MSXML2.XMLHTTP")
    oXHTTP.Open "GET", url, False
    oXHTTP.send
    ExecuteWebRequest = oXHTTP.responseText
    Set oXHTTP = Nothing
End Function

Rich (BB code):
Public Function outputtext(text As String)
Dim MyFile As String, fnum As String
        MyFile = ThisWorkbook.Path & "\temp.txt"
        fnum = FreeFile()
        Open MyFile For Output As fnum
        Print #fnum , text
        Close #fnum 
End Function

Rich (BB code):
Function GetAddress(HyperlinkCell As Range)
    GetAddress = Replace _
    (HyperlinkCell.Hyperlinks(1).Address, "mailto:", "")
End Function

Rich (BB code):
Dim objWeb As QueryTable
        Set objWeb = ActiveSheet.QueryTables.Add(Connection:="URL;https://tatts.com/racing/" _
        & Format(Sheets("Selections").Range("D3").Value, "DD/MM/YYYY") & "/RaceDay", _
        Destination:=Range("$A$1"))
  With objWeb
        .WebSelectionType = xlSpecifiedTables
        .WebFormatting = xlWebFormattingAll
        .WebTables = "2"
        .SaveData = True
        .Refresh BackgroundQuery:=False
    End With
Set objWeb = Nothing

Rich (BB code):
formhtml = ExecuteWebRequest(ThisWorkbook.Sheets("Meetings").Range("V1").Value)
    outputtext (formhtml)
    Set temp_qt = ThisWorkbook.Sheets("Race").QueryTables.Add(Connection:= _
            "URL;" & ThisWorkbook.Path & "\temp.txt" _
            , Destination:=ThisWorkbook.Sheets("Race").Range("$A$1"))
    With temp_qt
        .RefreshStyle = xlOverwriteCells
        .WebSelectionType = xlSpecifiedTables
        .WebFormatting = xlWebFormattingNone
        .WebTables = "13,17"
        .SaveData = True
        .Refresh BackgroundQuery:=False
        End With
Set temp_qt = Nothing
    Kill ThisWorkbook.Path & "\temp.txt"
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)

Forum statistics

Threads
1,223,900
Messages
6,175,276
Members
452,629
Latest member
SahilPolekar

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