LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.xml
external usenet poster
 
Posts: 4
Default Excel VBA, XMTHTTP & Cookies

(Sorry about cross-posting; I'm not sure which group is the best one for
this question.)

I need to get data into Excel from a web site which requires some sort
of authentication. As far as I can tell, the authentication is in the
form of a cookie or two.

I have successfully extracted data from websites using VBA and the
XMLHTTP object, and even from this site in the case where authentication
is not required.

However, I cannot seem to send cookies from VBA. I have a sample
procedure which tests my coding against a test site which displays form
data and cookies:

Sub test()
Dim x As New XMLHTTP
Dim t As String
x.Open "get", "http://www.comparity.net/perl/form.pl", False
x.setRequestHeader "Cookie", "one=foo;two=bar;"
x.setRequestHeader "Cookie", "one=foo;two=bar;"
x.send
t = x.responseText
WriteTextFile "c:\test.html", t
Debug.Print x.Status
Debug.Print t
End Sub

The repeated setRequestHeader code is to handle a bug, as listed in the
kb article:

http://support.microsoft.com/kb/290899

though I'm not 100% sure that it applies in this case.

The WriteTextFile procedure is used so I can read the response, and is
listed below:

Sub WriteTextFile(FileName, Text)
Const ForReading = 1, ForWriting = 2, ForAppending = 3
Dim fs, f
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.OpenTextFile(FileName, ForWriting, -2)
f.Write Text
f.Close
End Sub

So, does anybody have any idea why my cookies are not being sent, or how
I can send them some other way?

Thanks,

Mark
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I enable cookies, Icannot download Excel from My documen Arthur Vermont Australia Excel Discussion (Misc queries) 2 June 5th 09 04:48 AM
Eat Cookies and Loss Weight. See How Cooking.us Excel Worksheet Functions 1 June 30th 07 02:37 PM
How do I disable cookies? Learner New Users to Excel 1 September 7th 06 09:33 PM
Need help with cookies also [email protected] Excel Discussion (Misc queries) 0 July 9th 06 07:12 PM
Web Query & Cookies Pablo Chemes Excel Programming 0 July 16th 03 06:03 PM


All times are GMT +1. The time now is 08:20 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"