Excel Install Microsoft Winhttp Services

To update exchange rate from Yahoo Finance, press ALT+F11 Tools References enable “Microsoft WinHTTP Services”. Select the converter worksheet, click on the button in Cell B1 to get the latest exchange rate from Yahoo Finance, the exchange rate will be updated in column D of config worksheet, also the conversion amount in converter. The “x” flag is available only on Windows Server 2003 and later operating systems, and on the MSI redistributable version 3.0, and on later versions of the MSI redistributable. “.” – Wildcard, log all information except for the v and the x option. I would like to stream data from a websocket server using VBA in an Excel workbook. This is the actual data stream I would like to receive and process in VBA: Would you recommend using WinHttpRequest (WinHTTP Services) or any other service to connect and receive the websocket data?

  1. Excel Install Microsoft Winhttp Services Version
  2. Excel Install Microsoft Winhttp Services
-->

Excel Install Microsoft Winhttp Services Version

This topic provides information about using the WinHTTP WinHttpRequest COM object with scripting languages. For more information, including the C++ API (WinHTTP) please see About WinHTTP. See Choosing a WinHTTP Interface for a comparison of these interfaces.

Example

Code examples taken from IWinHttpRequest::Status property.

Members

The WinHttpRequest object has these types of members:

Excel

Events

The WinHttpRequest object has these events.

EventDescription
OnErrorOccurs when there is a run-time error in the application.
OnResponseDataAvailableOccurs when data is available from the response.
OnResponseFinishedOccurs when the response data is complete.
OnResponseStartOccurs when the response data starts to be received.

Methods

The WinHttpRequest object has these methods.

MethodDescription
AbortAborts a WinHTTPSend method.
GetAllResponseHeadersRetrieves all HTTP response headers.
GetResponseHeaderRetrieves the HTTP response headers.
OpenOpens an HTTP connection to an HTTP resource.
SendSends an HTTP request to an HTTP server.
SetAutoLogonPolicySets the current Automatic Logon Policy.
SetClientCertificateSelects a client certificate to send to a Secure Hypertext Transfer Protocol (HTTPS) server.
SetCredentialsSets credentials to be used with an HTTP server either an origin or a proxy server.
SetProxySets proxy server information.
SetRequestHeaderAdds, changes, or deletes an HTTP request header.
SetTimeoutsSpecifies, in milliseconds, the individual time-out components of a send/receive operation.
WaitForResponseSpecifies the wait time, in seconds, for an asynchronous Send method to complete, with optional time-out value.

Properties

The WinHttpRequest object has these properties.

PropertyAccess typeDescription
Option
Read/write
Sets or retrieves a WinHTTP option value.
ResponseBody
Read-only
Retrieves the response entity body as an array of unsigned bytes.
ResponseStream
Read-only
Retrieves the response entity body as an IStream.
ResponseText
Read-only
Retrieves the response entity body as text.
Status
Read-only
Retrieves the HTTP status code from the last response.
StatusText
Read-only
Retrieves HTTP status text.

Remarks

Excel Install Microsoft Winhttp Services

The WinHttpRequest object uses the IErrorInfo interface to provide error data. A description and numerical error value can be obtained with the Err object in Microsoft Visual Basic Scripting Edition (VBScript), and the Error object in Microsoft JScript. The lower 16 bits of an error number correspond to the values found in Error Messages.

Note

For Windows XP and Windows 2000, see Run-Time Requirements.

Requirements

RequirementValue
Minimum supported client
Windows XP, Windows 2000 Professional with SP3 [desktop apps only]
Minimum supported server
Windows Server 2003, Windows 2000 Server with SP3 [desktop apps only]
Redistributable
WinHTTP 5.0 and Internet Explorer 5.01 or later on Windows XP and Windows 2000.
IDL
HttpRequest.idl
Library
Winhttp.lib
DLL
Winhttp.dll

Excel Install Microsoft Winhttp Services

See also

In this article, we will create an Excel function to calculate the distance between two addresses using the Google Maps directions API. This will allow you to get the travel time between the two locations. The format of the function will be as follows: =TRAVELTIME(origin, destination, api_key), =TRAVELDISTANCE(origin, destination, apikey). The origin and destination will be strings, and can be either an exact address or the name of a place. In order to use the function, an API key is required. The “Getting Started” page can help you with this: http://bit.ly/googlemapsgettingstarted. Create a new project and make sure the Directions API is added.

Step 1: Create a new macro file and add VBA-JSON

Because the Google Maps Directions API is a JSON API, we will use VBA-JSON to make it easy to use the results from the web request. You can download the latest version from here: https://github.com/VBA-tools/VBA-JSON/releases. Download and extract the zip file. Then, open your macro file. Open the Visual Basic Editor (Alt + F11).

In order to import the VBA-JSON file, go to File > Import File… (Ctrl + M). Select JsonConverter.bas. A JsonConverter module will appear in the sidebar.

Next, make sure the appropriate references are enabled. Go to Tools > References… In addition to the references already selected, check off “Microsoft Scripting Runtime” (for Dictionary support needed by VBA-JSON) and “Microsoft WinHTTP Services, version 5.1” (to make the HTTP request to the API). If you require support for Excel for Mac, you will need to install VBA-Dictionary from the author of VBA-JSON. More details can be found at the bottom of the project homepage: https://github.com/VBA-tools/VBA-JSON.

Step 2: Create the functions

With the references configured, we can now write the code for the function. The code is relatively simple. It is simply takes the three parameters and formats them into a web request. The response of the web request is then parsed by VBA-JSON and the relevant variable returned. Note that the request may return multiple routes, but then function simply returns the time of the first route. The default mode is driving, but refer to the Directions API documentation for information on other modes and adjust the strURL variable accordingly.

To insert the code, create a new module with Insert > Module. Then paste the following code:

Save the file. You should now be able to use the functions from within Excel. Place your API key in cell A1, then try the following: =TRAVELTIME('24 Sussex Drive Ottawa ON', 'Parliament Hill', A1). This returns a travel time of about 435 seconds. If you would like this to be displayed in minutes and seconds, try this function: =FLOOR.MATH(A8/60)&' minutes '&MOD(A8, 60)&' seconds' where A8 is the cell with the travel time in seconds. This prints a helpful “7 minutes 15 seconds” for the 24 Sussex example. We can also find the distance. Try the following: =TRAVELDISTANCE('24 Sussex Drive Ottawa ON', 'Parliament Hill', A1). It returns a distance of 2667 meters. Convert to kilometers with this: =ROUND(A9/1000, 1)&' km'.

Note: The Google Maps Directions API always returns distances in meters. Convert to KM or Miles as you wish. This can be done in Excel or by modifying the functions in VBA.

That’s it! You should now have a working travel time function. All you need now is a list of addresses to use it with. If you would like to pull a list from the web or local JSON file, check out Import JSON Data in Excel 2016 or 2019 or Office 365 using a Get & Transform Query.