Greetings,
I'm having some problems with my current VBA script in Excel. The goal
is to get a table from a website with the QueryTables function. Well,
works fine so far. But to access the data which I need, I have to
login (username/password).
The login form runs with the POST method.
Here is the current sourcecode
Things you need to change to test this code:Code:Sub Test() Dim MyPost As String Const MyUrl As String = "http://some-url" '<<<<<<<< Change this URL. Const PostUser As String = "user=Username" '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
- URL: Just find a webpage with a login form, and copy the URL in the
proper string.
- Username-Field: Take a look at the sourcecode of the webpage. Look
for the input fields name, and put it before the username
- Password-Field: Same with username-field.
Things I checked so far:
- Correct name of the input boxes
- Correct URL
Now, why won't it just work? Do you guys have any ideas?
PS: Running Vista and Excel 2007
--
pmw2600




Reply With Quote