Post form variables to web query

Excel Help for Post form variables to web query in Automating Data Analysis Tasks

Find Excel Solutions


Search the Forums:
Recent Activity:
Delete Cell Items In Spreadsheet
Importing Data From Pdf Files
New Portfolio Optimization Template Version
Financial Market Data Feed
Run Time Error 1004
Data Downloader Crashes Excel




Follow Business Spreadsheets On:
 
Forum TopicLogin
Post form variables to web query
Rate this:
(2.7/5 from 10 votes)
HappyYou can post form variables to a web query in order to automatically login to a page and retrieve its data.  You need to know the name of the form variables required by the page.  This information can be obtained by right cliking of the page that requires the information and chossing to "View Source".  The names of the form variables that are required to be posted are the values of the "name" attributes for the elements within the "form" tag.

The following VBA code shows how to login into this forum and access this post:

VBA Code:
Sub Login_WebQuery()
Dim MyPost As String
Const MyUrl As String = "http://www.business-spreadsheets.com/forum.asp?t=103"
Const PostUser As String = "login=User Name" 'Change user name here
Const PostPassword As String = "&pass=password" 'Change password here
   
MyPost = PostUser & PostPassword
   
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

 Excel Business Forums Administrator
 Posted by on
[View the Full Thread for the "Automating a web query login to download data" Topic]

Find relevant Excel templates and add-ins for Post form variables to web query in the

 
Find Excel templates
and add-ins in the
Excel Business Solutions Directory

       
  © 2013 Business Spreadsheets. All Rights Reserved. Legal |