IBrowserPool Interface coclass BrowserPool | Multi-browser pool pattern | All methods take browserIndex As Long

Note

IBrowserPool mirrors most of ILiteView2Ctrl's functionality but adds browserIndex As Long as the first parameter to every method. This page documents only the pool-specific methods. For shared methods (Navigate, ExecuteScript, PushRecordset, etc.), see the ILiteView2Ctrl reference — just add browserIndex as the first argument.

Getting Started — Reg-Free Setup

Before you can use IBrowserPool, add this standard module to your project. It declares the Win32 API calls needed to load the OCX without COM registration, then exposes a GetPool() singleton you can call from any form.

Place the OCX in the same folder as your .accdb or .xlsm.

modLV2Pool.bas — add once per project

Option Explicit

' --- Win32 + OCX declarations (64-bit / 32-bit) ---
#If Win64 Then
    Private Declare PtrSafe Function SetDllDirectory Lib "kernel32" _
        Alias "SetDllDirectoryW" (ByVal lpPathName As LongPtr) As Long
    Private Declare PtrSafe Function LiteView2_ActivateManifest _
        Lib "LiteView2_x64.ocx" (ByVal path As LongPtr) As Long
    Private Declare PtrSafe Function LiteView2_CreateBrowserPool _
        Lib "LiteView2_x64.ocx" () As Object
#Else
    Private Declare PtrSafe Function SetDllDirectory Lib "kernel32" _
        Alias "SetDllDirectoryW" (ByVal lpPathName As LongPtr) As Long
    Private Declare PtrSafe Function LiteView2_ActivateManifest _
        Lib "LiteView2_x86.ocx" (ByVal path As LongPtr) As Long
    Private Declare PtrSafe Function LiteView2_CreateBrowserPool _
        Lib "LiteView2_x86.ocx" () As Object
#End If

Private m_Pool As Object

Public Function GetPool() As Object
    If m_Pool Is Nothing Then
        Dim p As String
        p = CurrentProject.Path          ' Access  (Excel: ThisWorkbook.Path)
        SetDllDirectory StrPtr(p)        ' Tell Windows where the OCX lives
        #If Win64 Then
            LiteView2_ActivateManifest StrPtr(p & "\LiteView2_x64.ocx")
        #Else
            LiteView2_ActivateManifest StrPtr(p & "\LiteView2_x86.ocx")
        #End If
        Set m_Pool = LiteView2_CreateBrowserPool()
        m_Pool.ActivateLicense "Your Company", "YOUR-LICENSE-KEY"  ' omit this line during 30-day trial
    End If
    Set GetPool = m_Pool
End Function

Usage from any form

Dim pool As Object
Set pool = GetPool()

' Create a browser and embed it in a Frame control
Dim idx As Long
idx = pool.CreateInControl("about:blank", Me.Frame1)

' Map a local folder to the virtual hostname https://lv2.local/
pool.SetLocalContentRoot idx, CurrentProject.Path & "\html"

' Navigate to a local HTML file
pool.Navigate idx, "https://lv2.local/dashboard.html"
What is lv2.local?

SetLocalContentRoot maps a folder on disk to the virtual hostname https://lv2.local/. Files in that folder are then accessible via URLs like https://lv2.local/dashboard.html. This avoids file:// URLs (which have security restrictions) and gives your local HTML files a proper HTTPS origin. See ILiteView2Ctrl › Local Content Mapping for details.

Licensing

ActivateLicense is called once per process, before creating any browser instances. The recommended place is inside GetPool(), right after LiteView2_CreateBrowserPool():

m_Pool.ActivateLicense "Your Company", "YOUR-LICENSE-KEY"
Trial & Activation

A 30-day trial starts automatically — all features are fully functional with no limitations. After trial expiry, the control displays a watermark and API methods return E_ACCESSDENIED. Add the ActivateLicense line with your purchased key to activate immediately. No license files, no registry entries — just one line of VBA code.

Reg-Free (IBrowserPool)

' Inside GetPool(), right after LiteView2_CreateBrowserPool()
m_Pool.ActivateLicense "My Company", "LICENSE-KEY-HERE"

Registered (Design-Time Control)

' In your Form_Load or WebViewReady event
m_lv.ActivateLicense "My Company", "LICENSE-KEY-HERE"

License Status Properties

' Works on both pool and control objects
Debug.Print "Status: " & obj.LicenseStatus
Debug.Print "Type: "   & obj.LicenseType
Debug.Print "State: "  & obj.LicenseState       ' 0=Valid, 1=Trial, 2=Expired, 3=Invalid
Debug.Print "Days: "   & obj.TrialDaysRemaining

Key Difference

Every ILiteView2Ctrl method gains a browserIndex As Long first parameter on IBrowserPool:

' ILiteView2Ctrl (design-time OCX — single browser)
m_lv.Navigate "https://example.com"
m_lv.PushRecordset rs, "onData"

' IBrowserPool (multi-browser pool — add browserIndex)
pool.Navigate browserIndex, "https://example.com"
pool.PushRecordset browserIndex, rs, "onData"
Create & Destroy 5 methods

Create and destroy browser instances in the pool. Each Create call returns a unique index (1, 2, 3...) or 0 on failure.

MemberParametersReturnsDescription
CreatehwndParent As Long, url As String, x As Long, y As Long, width As Long, height As LongLongCreate browser, returns index (1,2,3...) or 0 on failure
DestroybrowserIndex As LongDestroy browser
DestroySyncbrowserIndex As LongDestroy synchronously
CreateWithProfilehwndParent As Long, url As String, x As Long, y As Long, w As Long, h As Long, profileName As StringLongCreate with named profile
CreateWithProfileInPrivatehwndParent As Long, url As String, x As Long, y As Long, w As Long, h As Long, profileName As StringLongCreate with InPrivate profile

Create & Destroy Example

Source: frmLifecycleCore_Code.txt

' Create a browser in the pool
Dim idx As Long
idx = pool.Create(Me.hwnd, "about:blank", 0, 0, 800, 600)
If idx = 0 Then
    MsgBox "Failed to create browser"
    Exit Sub
End If

' Map local folder to https://lv2.local/ (call once per browser)
pool.SetLocalContentRoot idx, CurrentProject.Path & "\html"

' Navigate to a local HTML file
pool.Navigate idx, "https://lv2.local/dashboard.html"

' Cleanup
pool.Destroy idx
Parking 3 methods

Park browsers to hide them while preserving state for later reuse, or destroy all parked browsers at once.

MemberParametersReturnsDescription
ParkbrowserIndex As LongHide browser (park) — preserves state for reuse
DestroyAllParkedLongDestroy all parked browsers, returns count destroyed
GetParkedBrowserCountLongCount of currently parked browsers

Parking Example

' Park a browser to free resources but keep state
pool.Park browserIndex
Debug.Print "Parked browsers: " & pool.GetParkedBrowserCount

' Later: destroy all parked browsers
Dim freed As Long
freed = pool.DestroyAllParked
Debug.Print "Freed " & freed & " browsers"
Embedding 4 methods

Embed browsers into VBA Frame controls or reparent them to different windows.

MemberParametersReturnsDescription
EmbedInControlbrowserIndex As Long, control As ObjectEmbed browser in VBA Frame control
CreateInControlurl As String, control As ObjectLongCreate + embed in one call, returns index
CreateInControlWithProfileurl As String, control As Object, profileName As StringLongCreate + embed with named profile
ReparentbrowserIndex As Long, hwndNewParent As Long, x As Long, y As Long, w As Long, h As LongMove browser to new parent window

Embedding Example

Source: src\frmBrowser.cls

' Map local folder first (required for lv2.local URLs)
pool.SetLocalContentRoot idx, CurrentProject.Path & "\html"

' Create and embed in an Access Frame control in one call
Dim idx As Long
idx = pool.CreateInControl("https://lv2.local/app.html", Me.fraWebView)
If idx > 0 Then
    m_browserIndex = idx
End If
Profiles 5 methods

Manage browser profiles, InPrivate mode, and browsing data per browser instance.

MemberParametersReturnsDescription
GetProfileNamebrowserIndex As LongStringGet profile name for browser
IsInPrivateModebrowserIndex As LongBooleanCheck if browser is InPrivate
GetProfilePathbrowserIndex As LongStringOn-disk profile folder path
ClearProfileBrowsingDatabrowserIndex As Long, dataKinds As LongClear browsing data by kind flags
ClearProfileBrowsingDataAllbrowserIndex As LongClear all browsing data for profile
Management 7 methods

Manage browser lifecycle, visibility, sizing, and suspension state.

MemberParametersReturnsDescription
IsValidIndexbrowserIndex As LongBooleanCheck if browser index is still valid
GetBrowserCountLongCount of active browsers in pool
ResizebrowserIndex As Long, x As Long, y As Long, width As Long, height As LongResize browser
SetVisiblebrowserIndex As Long, visible As BooleanSet browser visibility
TrySuspendbrowserIndex As LongSuspend browser to save resources
ResumeBrowserbrowserIndex As LongResume suspended browser
IsSuspendedbrowserIndex As LongBooleanCheck if browser is suspended
Runtime Detection 3 methods
Note

These methods do NOT take a browserIndex parameter — they query the system.

MemberParametersReturnsDescription
IsWebView2RuntimeInstalledBooleanCheck if WebView2 runtime is installed
GetWebView2RuntimeVersionStringGet installed runtime version string
GetWebView2RuntimePathStringGet runtime installation path

Runtime Detection Example

' Check runtime before creating browsers
If Not pool.IsWebView2RuntimeInstalled Then
    MsgBox "WebView2 runtime not found. Please install it."
    Exit Sub
End If
Debug.Print "Runtime version: " & pool.GetWebView2RuntimeVersion
VBA Auto-Dispatch & Callbacks 6 methods

Allow JavaScript in the browser to call VBA macros directly, without manual WebMessageReceived routing.

MemberParametersReturnsDescription
EnableAutoDispatchbrowserIndex As Long, enabled As BooleanEnable or disable auto-dispatch of HTML/JS calls to VBA macros
IsAutoDispatchEnabledbrowserIndex As LongBooleanCheck whether auto-dispatch is currently enabled for this browser
SetAllowedVBAMacrosbrowserIndex As Long, macroList As StringSet comma-separated whitelist of VBA macro names that JS is allowed to call
ClearAllowedVBAMacrosbrowserIndex As LongClear the VBA macro whitelist (blocks all auto-dispatch calls)
RegisterVbaCallbackbrowserIndex As Long, jsName As String, callbackObject As Object, methodName As StringRegister a VBA object method as a callable function from JavaScript. jsName is the name JS uses to call it.
UnregisterVbaCallbackbrowserIndex As LongUnregister all VBA callbacks for this browser
Audio Control 3 methods

Query and control audio playback state for a browser instance.

MemberParametersReturnsDescription
GetIsDocumentPlayingAudiobrowserIndex As LongBooleanCheck if the document is currently playing audio
GetIsMutedbrowserIndex As LongBooleanGet the current mute state of the browser
SetIsMutedbrowserIndex As Long, muted As BooleanMute or unmute the browser audio
Pool-Only Utilities 6 methods

Additional methods available only on IBrowserPool (not on ILiteView2Ctrl).

MemberParametersReturnsDescription
GetUserAgentbrowserIndex As LongStringGet the current User-Agent string for this browser
SetDefaultBackgroundColorbrowserIndex As Long, argbColor As LongSet the default background color as ARGB (e.g. &HFF000000 for opaque black)
ShowSaveAsDialogbrowserIndex As LongShow the browser's native Save As dialog
GetLastErrorbrowserIndex As LongStringGet the last error message for this browser instance
GetLastErrorCodebrowserIndex As LongLongGet the last error code (HRESULT) for this browser instance
DestroyBrowserSyncbrowserIndex As Long, timeoutMs As LongSynchronously destroy a browser with a timeout. Blocks until the browser is destroyed or the timeout expires.

Shared Methods Reference

All other ILiteView2Ctrl methods are available on IBrowserPool with browserIndex as the first parameter. See the ILiteView2Ctrl reference for full documentation.

CategoryMethodsReference
NavigationNavigate, GoBack, GoForward, etc.ILiteView2Ctrl › Navigation
Script ExecutionExecuteScript, ExecuteScriptWithArgs, etc.ILiteView2Ctrl › Script Execution
Data BridgePostWebMessageAsJson, PushRecordset, CallJsFunction, SetJsVariable, etc.ILiteView2Ctrl › Data Bridge
JSON HelpersBuildJson, JsonGetValue, JsonIsValid, etc.ILiteView2Ctrl › JSON Helpers
JSON MutationJsonCreateObject, JsonSetValue, JsonMerge, JsonToRowArray, JsonUnwrapString, JsonCompact, etc.ILiteView2Ctrl › JSON Mutation
Automation APIWaitForElement, ClickElementBySelector, GetTextBySelectorILiteView2Ctrl › Automation API
DOM ManipulationGetElementValueById, SetInnerHtmlById, etc.ILiteView2Ctrl › DOM Manipulation
Printing & PDFPrintToPdf, CaptureScreenshot, etc.ILiteView2Ctrl › Printing & PDF
SettingsIsScriptEnabled, UserAgent, etc.ILiteView2Ctrl › Settings
Cookies & StorageGetCookies, SetCookie, etc.ILiteView2Ctrl › Cookies & Storage
Stealth ModeEnableStealthMode, SpoofWebGL, etc.ILiteView2Ctrl › Stealth Mode
Document HostingOpenDocument, OpenOfficeDocument, etc.ILiteView2Ctrl › Document Hosting
Find in PageStartFind, FindNext, StopFind, etc.ILiteView2Ctrl › Find in Page
LifecycleTrySuspend, Resume, Dispose, etc.ILiteView2Ctrl › Lifecycle
CAPTCHADetectCaptcha, SolveCaptcha, etc.ILiteView2Ctrl › CAPTCHA
DownloadsAllowDownloads, PauseDownload, etc.ILiteView2Ctrl › Downloads
Web ResourcesAddWebResourceRequestedFilter, etc.ILiteView2Ctrl › Web Resources
Auth & ProxySetBasicAuthCredentials, etc.ILiteView2Ctrl › Auth & Proxy
Host ObjectsAddHostObjectToScript, etc.ILiteView2Ctrl › Host Objects
DevToolsCallDevToolsProtocolMethod, etc.ILiteView2Ctrl › DevTools
EmbeddingEmbedInHwnd, QuickInitInFrame, etc.ILiteView2Ctrl › Embedding
LicensingActivateLicense, LicenseState, etc.ILiteView2Ctrl › Licensing
Explore More:
Core API | Events | JSON | Browser Pool | Enumerations