Solved

VBA WinHttp.WinHTTPRequest

Posted on 2010-11-17
2
5,100 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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

863 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now