|
-
Nov 12th, 2008, 03:34 AM
#1
Thread Starter
New Member
[Excel] Can't Login via QueryTables to a Webpage (POST Method)
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
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
Things you need to change to test this code:
- 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
-
Nov 12th, 2008, 10:03 AM
#2
Re: [Excel] Can't Login via QueryTables to a Webpage (POST Method)
Welcome to the forums. 
What happens when you run it? Are you getting an error? If so, what?
-
Nov 12th, 2008, 10:17 AM
#3
Thread Starter
New Member
Re: [Excel] Can't Login via QueryTables to a Webpage (POST Method)
Thanks!
Well, there is no error actually. It just doesn't login. I can see that if I look at the return string of the QueryTable object.
--
pmw2600
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|