Solved

VBA WinHttp.WinHTTPRequest

Posted on 2010-11-17
2
4,958 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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…

746 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

11 Experts available now in Live!

Get 1:1 Help Now