Home > Forum Home > Automating Data Analysis Tasks > Download Historical NAV form web > Post Variables using PostText Share

Post Variables using PostText

Excel Help for Post Variables Using Posttext in Automating Data Analysis Tasks


Forum TopicLogin

Post Variables Using Posttext

Rate this:
(3/5 from 1 vote)
SadIn your code you are sending variables in the URL.  You need to post them using the PostText command so that your code would look more like:

VBA Code:
Sub downloadnav()
Dim wst As Worksheet
Dim MyPost As String
Const MyUrl As String = "http://www.idbifortis.com/TrackNAV.aspx?lm1=1"
   
MyPost = "TxtDate=04-Nov-2009"
'This is where you need to build your string from the date cell
'It may be better to format you cell as dd-mmm-yyy
'and then just take StrDate = Range("B5").Text
'then use MyPost = "TxtDate=" & strDate

'There are more parameters required when you look at the
'source HTML of the page in question:

MyPost = MyPost & "&CboFund=0&CboFund=0"

'Get the data
'-----------------------------------------------------------------------------------------------------
Sheets.Add
ActiveSheet.Name = "temp"
Sheets("temp").Select

'varconnection = MyUrl & TxtDate
      
        With ActiveSheet.QueryTables.Add(Connection:= _
            "URL;" & MyUrl, Destination:=Cells(1, 1))
            .PostText = MyPost
            .BackgroundQuery = True
            .TablesOnlyFromHTML = True
            .Refresh BackgroundQuery:=False
            .SaveData = True
        End With
End Sub

The page also has a session variable that you may need to capture first and post back. To do this is a bit more complicated but it is detailed in this post.

 Excel Business Forums Administrator
 Posted by on
 
View Full Post

Find relevant Excel templates and add-ins for Post Variables using PostText in the