Solved

VBA WinHttp.WinHTTPRequest

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
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 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…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

808 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