+ Reply to Thread
Results 1 to 5 of 5

dynamic web queries with vba

  1. #1
    Registered User
    Join Date
    08-20-2006
    Posts
    2

    dynamic web queries with vba

    Hello,

    I am trying to create multiple web queries where I pull in data in from a url where I have the urls (around 10 of them) in an excel workbook.

    Any help would be hugely appreciated.

    thanks

    Randy

  2. #2
    Pelham
    Guest

    Re: dynamic web queries with vba

    Dear Randy

    Did you ever solve this problem?

    I am trying to do the same thing with about 200 different web pages and
    am curious to know what your VBA script looks to do your action.

    Regards
    Pelham

    rbarning wrote:
    > Hello,
    >
    > I am trying to create multiple web queries where I pull in data in from
    > a url where I have the urls (around 10 of them) in an excel workbook.
    >
    > Any help would be hugely appreciated.
    >
    > thanks
    >
    > Randy
    >
    >
    > --
    > rbarning
    > ------------------------------------------------------------------------
    > rbarning's Profile: http://www.excelforum.com/member.php...o&userid=37787
    > View this thread: http://www.excelforum.com/showthread...hreadid=573544



  3. #3
    NickHK
    Guest

    Re: dynamic web queries with vba

    Randy,
    Record a macro when you create 1 web query.
    Modify the code to change the URL and Destination within a loop

    NickHK

    "rbarning" <rbarning.2cuflg_1156085409.6984@excelforum-nospam.com> wrote in
    message news:rbarning.2cuflg_1156085409.6984@excelforum-nospam.com...
    >
    > Hello,
    >
    > I am trying to create multiple web queries where I pull in data in from
    > a url where I have the urls (around 10 of them) in an excel workbook.
    >
    > Any help would be hugely appreciated.
    >
    > thanks
    >
    > Randy
    >
    >
    > --
    > rbarning
    > ------------------------------------------------------------------------
    > rbarning's Profile:

    http://www.excelforum.com/member.php...o&userid=37787
    > View this thread: http://www.excelforum.com/showthread...hreadid=573544
    >




  4. #4
    Registered User
    Join Date
    08-20-2006
    Posts
    2

    code for url pulls

    Yes I did.
    You can name the url as a parameter, I called it x.
    I did the range by multiplying the for next loop number by 200.
    I'm sure it is not the best code, but it works pretty good.

    Sub aaa()

    Dim x As String
    Dim webq As Integer

    For webq = 1 To range("F1")

    x = range("D" & webq)

    With ActiveSheet.QueryTables.Add(Connection:= _
    "URL;" & x, _
    Destination:=range("C" & webq * 200))
    .Name = "gamelog?playerId=4234"
    .FieldNames = True
    .RowNumbers = False
    .FillAdjacentFormulas = False
    .PreserveFormatting = True
    .RefreshOnFileOpen = False
    .BackgroundQuery = True
    .RefreshStyle = xlInsertDeleteCells
    .SavePassword = False
    .SaveData = True
    .AdjustColumnWidth = True
    .RefreshPeriod = 0
    .WebSelectionType = xlSpecifiedTables
    .WebFormatting = xlWebFormattingNone
    .WebTables = "1,5"
    .WebPreFormattedTextToColumns = True
    .WebConsecutiveDelimitersAsOne = True
    .WebSingleBlockTextImport = False
    .WebDisableDateRecognition = False
    .WebDisableRedirections = False
    .Refresh BackgroundQuery:=False
    End With



    application.CutCopyMode = False

    Next webq

    End Sub



    [QUOTE=Pelham]Dear Randy

    Did you ever solve this problem?

    I am trying to do the same thing with about 200 different web pages and
    am curious to know what your VBA script looks to do your action.

    Regards
    Pelham

  5. #5
    Pelham
    Guest

    Re: dynamic web queries with vba

    Wonderful people - thanks!

    rbarning wrote:
    > Yes I did.
    > You can name the url as a parameter, I called it x.
    > I did the range by multiplying the for next loop number by 200.
    > I'm sure it is not the best code, but it works pretty good.
    >
    > Sub aaa()
    >
    > Dim x As String
    > Dim webq As Integer
    >
    > For webq = 1 To range("F1")
    >
    > x = range("D" & webq)
    >
    > With ActiveSheet.QueryTables.Add(Connection:= _
    > "URL;" & x, _
    > Destination:=range("C" & webq * 200))
    > .Name = "gamelog?playerId=4234"
    > .FieldNames = True
    > .RowNumbers = False
    > .FillAdjacentFormulas = False
    > .PreserveFormatting = True
    > .RefreshOnFileOpen = False
    > .BackgroundQuery = True
    > .RefreshStyle = xlInsertDeleteCells
    > .SavePassword = False
    > .SaveData = True
    > .AdjustColumnWidth = True
    > .RefreshPeriod = 0
    > .WebSelectionType = xlSpecifiedTables
    > .WebFormatting = xlWebFormattingNone
    > .WebTables = "1,5"
    > .WebPreFormattedTextToColumns = True
    > .WebConsecutiveDelimitersAsOne = True
    > .WebSingleBlockTextImport = False
    > .WebDisableDateRecognition = False
    > .WebDisableRedirections = False
    > .Refresh BackgroundQuery:=False
    > End With
    >
    >
    >
    > application.CutCopyMode = False
    >
    > Next webq
    >
    > End Sub
    >
    >
    >
    > Pelham Wrote:
    > > Dear Randy
    > >
    > > Did you ever solve this problem?
    > >
    > > I am trying to do the same thing with about 200 different web pages
    > > and
    > > am curious to know what your VBA script looks to do your action.
    > >
    > > Regards
    > > Pelham

    >
    >
    > --
    > rbarning
    > ------------------------------------------------------------------------
    > rbarning's Profile: http://www.excelforum.com/member.php...o&userid=37787
    > View this thread: http://www.excelforum.com/showthread...hreadid=573544



+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1