-
-
Notifications
You must be signed in to change notification settings - Fork 507
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+F11orDeveloper > 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
-
AsyncWrapperis 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+horEdit > Replace) to replace the following:RestHelpers -> WebHelpersRestClient -> WebClientRestRequest -> WebRequestRestResponse -> WebResponseIAuthenticator -> IWebAuthenticatorStatusCodes -> WebStatusCodeAvailableMethods -> WebMethodAvailableFormats -> 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
WebAsyncWrapperto your project -
Add an explicit reference to WinHTTP
Tools > Referencesand selectMicrosoft WinHTTP Services, version 5.1 -
Find each instance of
ExecuteAsyncin 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 inResourceor 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 > GetUrlPartsand note that the returnedDictionaryhas an updated schema
- Moved
ExecuteAsync > WebAsyncWrapper.ExecuteAsync(See "Update async functionality" above) - Changed
ProxyBypassListfromVarianttoString
- Changes
Headers,QuerystringParams, andCookiesfromDictionarytoCollection - Removed
AddBody(use(Set) Request.Body = ...instead) - Removed
AddBodyString(useRequest.Body = "..."instead) - Removed
AddParameterin favor of explicitly usingAddQuerystringParamandAddBodyParameter - Removed
BaseUrl(Handled exclusively inWebClient) - Removed
FormatName - Moved
FullUrl > WebClient.GetFullUrl - Removed
IncludeCacheBreaker(No longer needed) - Removed
IncludeContentLengthAlways included, but value can be changed withContentLength - Removed
MethodName(UseWebHelpers.MethodToName) - Split
ParametersintoQuerystringParamsandBody - Removed
RequireHTTPS(Explicitly use https inBaseUrland/orResource) - Removed
RootElement(No longer needed) - Removed
StartTimeoutTimer,StopTimeoutTimer, andTimedOut
- Removed
BeforeOpen(usePrepareHttpandPrepareCurlinstead)