Solved

VBA WinHttp.WinHTTPRequest

Posted on 2010-11-17
2
5,725 Views
Last Modified: 2012-05-10
I have in Excel vba

Dim xhr As WinHttp.WinHTTPRequest
   
    Set xhr = CreateObject(WinHttp.WinHTTPRequest)

but this gives me "compile error user defined type not defined.

I must be missing a reference or something like but not too familiar with vba.

Help please
0
Comment
Question by:Philip Pinnell
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 22

Accepted Solution

by:
spattewar earned 500 total points
ID: 34156138
you have to put a reference to the Microsoft WinHTTP Services. In your VBA project window go to the menu Tools-> Reference and add the WinHTTP services. Then you should be able to compile. Also in your code you are doing both early and late binding which is not helpful.

If you do not want to add a reference to the services then you can do

Dim xhr As Object    
Set xhr = CreateObject(WinHttp.WinHTTPRequest)

and if you have added the reference then you should get the intellisense when you enter space after the As keyword

Dim xhr As WinHttp.WinHTTPRequest
   
    Set xhr = New WinHTTPRequest

Hope this helps.

0
 
LVL 13

Author Comment

by:Philip Pinnell
ID: 34156580
Thanks

That's what I needed
0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

687 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question