-
-
Notifications
You must be signed in to change notification settings - Fork 496
Upgrading from v3 to v4
VBA-Web v4.* includes some great new features (Mac support, general VBA compatibility, and lots of updates and bugfixes)
Here's how to transition from v3.* based project to v4.*
In later steps, the VBAProject will be compiled in an attempt to find items that need to changed. To make it easier to isolate only issues related to upgrading, compile your project before upgrading with Debug > Compile VBAProject
to make sure there are no issues before starting the upgrade.
Remove RestHelpers
, RestClient
, RestRequest
, RestResponse
, and IAuthenticator
from your project.
- Open Visual Basic editor (
Alt+F11
orDeveloper > Visual Basic
) - Right-click each Module/Class to remove
- Click "Remove (Filename)"
Open VBA-Web - Installer.xlsm
to install VBA-Web automatically in your workbook.
-
Browse for the workbook that you want to update
-
Select the components that you want to install
- Install / Update VBA-Web installs the VBA-Web source
-
AsyncWrapper
is used for providing async functionality (ExecuteAsync
) in Windows-only workbooks - Select any authenticators that you want to install
-
Click Install / Update
-
Use VBA's find-and-replace (
Ctrl+h
orEdit > Replace
) to replace the following:RestHelpers -> WebHelpers
RestClient -> WebClient
RestRequest -> WebRequest
RestResponse -> WebResponse
IAuthenticator -> IWebAuthenticator
StatusCodes -> WebStatusCode
AvailableMethods -> WebMethod
AvailableFormats -> WebFormat
Currently, async functionality is Windows-only and has been been moved out of the core VBA-Web source. Follow these steps to update any async code you may have:
-
Add
WebAsyncWrapper
to your project -
Add an explicit reference to WinHTTP
Tools > References
and selectMicrosoft WinHTTP Services, version 5.1
-
Find each instance of
ExecuteAsync
in your project and replace with the following:' Before Client.ExecuteAsync Request, "Callback", Array(Arg1, Arg2) ' After ' Create async wrapper that wraps Client Dim Wrapper As New WebAsyncWrapper Set Wrapper.Client = Client Wrapper.ExecuteAsync Request, "Callback", Array(Arg1, Arg2)
Some of the API for Excel-REST has changed in the transition to VBA-Web to enable Mac functionality, upgrade internals, and remove bugs. Use the following steps to identify and fix these issues:
-
{format}
UrlSegment is no longer automatically replaced inResource
, set format directly inResource
or useAddUrlSegment("format", "...")
- Compile VBAProject to identify any compilation errors (
Debug > Compile VBAProject
) - Use the following mapping to resolve any issues:
- Removed
AddToDictionary
(UseDictionary.Add
/Dictionary("...")
directly) - Removed
BytesToHex
- Removed
BytesToBase64
- Removed
BytesToFormat
- Removed
Base64_HMACSHA1
- Removed
CombineObjects
- Removed
CreateResponse
- Moved
CreateResponseFromHttp > WebResponse.CreateFromHttp
- Moved
CreateRequestFromOptions > WebRequest.CreateFromOptions
- Removed
EncodeBase64
- Removed
EncodeStringToBase64
- Removed
ExecuteRequest
(Handled directly inWebClient
) - Removed
ExecuteRequestAsync
(Handled directly inWebAsyncWrapper
) - Moved
ExtractCookiesFromHeaders > WebResponse.ExtractCookies
- Moved
ExtractHeadersFromResponseHeaders > WebResponse.ExtractHeaders
- Removed
FilterObject
- Renamed
FormatToContentType > FormatToMediaType
- Removed
FormatToName
- Removed
IncludesProtocol
(UseGetUrlParts
) - Removed
IsArray
(UseVBA.IsArray
) - Removed
HMACSHA1AsBytes
- Removed
HMACSHA256AsBytes
- Removed
MD5AsBytes
- Moved
PrepareHttpRequest > WebClient.PrepareHttpRequest
- Removed
PrepareProxyForHttpRequest
- Removed
RemoveProtocol
- Removed
SetHeaders
- Removed
SortDictionary
(Was never implemented) - Renamed
StringToBytes > StringToAnsiBytes
- Moved
UpdateResponse > WebResponse.Update
- Renamed
UrlParts > GetUrlParts
and note that the returnedDictionary
has an updated schema
- Moved
ExecuteAsync > WebAsyncWrapper.ExecuteAsync
(See "Update async functionality" above) - Changed
ProxyBypassList
fromVariant
toString
- Changes
Headers
,QuerystringParams
, andCookies
fromDictionary
toCollection
- Removed
AddBody
(use(Set) Request.Body = ...
instead) - Removed
AddBodyString
(useRequest.Body = "..."
instead) - Removed
AddParameter
in favor of explicitly usingAddQuerystringParam
andAddBodyParameter
- Removed
BaseUrl
(Handled exclusively inWebClient
) - Removed
FormatName
- Moved
FullUrl > WebClient.GetFullUrl
- Removed
IncludeCacheBreaker
(No longer needed) - Removed
IncludeContentLength
Always included, but value can be changed withContentLength
- Removed
MethodName
(UseWebHelpers.MethodToName
) - Split
Parameters
intoQuerystringParams
andBody
- Removed
RequireHTTPS
(Explicitly use https inBaseUrl
and/orResource
) - Removed
RootElement
(No longer needed) - Removed
StartTimeoutTimer
,StopTimeoutTimer
, andTimedOut
- Removed
BeforeOpen
(usePrepareHttp
andPrepareCurl
instead)