| title | Properties |
|---|---|
| parent | WebView2 Package |
| nav_order | 6 |
The WebView2 control provides rich properties to control its behavior and state.
Sets the URL to open. URIs need a protocol prefix, such as http://. For example: https://www.google.com
Type: String (Read-only)
Example:
WebView21.Navigate "https://www.example.com"
Debug.Print WebView21.DocumentURLReturns the current document title provided by HTML content.
Type: String (Read-only)
Example:
Me.Caption = WebView21.DocumentTitleSets or gets the overall zoom factor. For example, a value of 1.5 represents a 50% zoom.
Type: Double
Example:
WebView21.ZoomFactor = 1.5 ' Zoom in 50%
Debug.Print WebView21.ZoomFactorGets the ProcessID of the external browser EXE process.
Type: Long (Read-only)
Example:
Debug.Print "Browser Process ID: " & WebView21.BrowserProcessIdDetermines if there is backward navigation history.
Type: Boolean (Read-only)
Example:
If WebView21.CanGoBack Then
WebView21.GoBack
End IfDetermines if there is forward navigation history.
Type: Boolean (Read-only)
Example:
If WebView21.CanGoForward Then
WebView21.GoForward
End IfReturns the container window handle.
Type: LongPtr (Read-only)
Example:
Debug.Print "Window Handle: 0x" & Hex(WebView21.hWnd)Controls whether JavaScript is enabled within the webview.
Type: Boolean (Read/Write)
Default Value: True
Example:
WebView21.IsScriptEnabled = False ' Disable JavaScriptControls whether PostWebMessage functionality is enabled.
Type: Boolean (Read/Write)
Default Value: True
Example:
WebView21.IsWebMessageEnabled = TrueControls whether default script dialogs are enabled (such as JavaScript alert() function). Set to False and listen to ScriptDialogOpening event to implement your own dialogs.
Type: Boolean (Read/Write)
Default Value: True
Example:
WebView21.AreDefaultScriptDialogsEnabled = FalseControls whether the status bar is enabled.
Type: Boolean (Read/Write)
Default Value: True
Example:
WebView21.IsStatusBarEnabled = FalseControls whether users are allowed to open DevTools through context menu or accelerator keys (does not affect OpenDevToolsWindow function).
Type: Boolean (Read/Write)
Default Value: True
Example:
WebView21.AreDevToolsEnabled = FalseControls whether the default Edge context menu is enabled. Set to False and listen to UserContextMenu event to use your own.
Type: Boolean (Read/Write)
Default Value: True
Example:
WebView21.AreDefaultContextMenusEnabled = FalseControls whether AddObject functionality can be used to share host COM objects with the JavaScript engine.
Type: Boolean (Read/Write)
Default Value: True
Example:
WebView21.AreHostObjectsAllowed = TrueControls whether users can change the zoom factor using Ctrl++/Ctrl+-/Ctrl+mouse wheel.
Type: Boolean (Read/Write)
Default Value: True
Example:
WebView21.IsZoomControlEnabled = FalseControls whether the built-in error page is enabled (such as 404 navigation errors).
Type: Boolean (Read/Write)
Default Value: True
Example:
WebView21.IsBuiltInErrorPageEnabled = FalseSets the UserAgent string to be used in HTTP request headers.
Type: String (Read/Write)
Example:
WebView21.UserAgent = "MyApp/1.0"Note: Use SupportsUserAgentFeatures to check if this feature is supported.
Controls whether all default accelerator keys are enabled. For example, F5 to reload.
Type: Boolean (Read/Write)
Default Value: True
Example:
WebView21.AreBrowserAcceleratorKeysEnabled = FalseNote: Use SupportsAcceleratorKeysFeatures to check if this feature is supported.
Controls whether password information is automatically saved.
Type: Boolean (Read/Write)
Default Value: True
Example:
WebView21.IsPasswordAutoSaveEnabled = FalseNote: Use SupportsAutoFillFeatures to check if this feature is supported.
Controls whether general form information is saved and auto-filled.
Type: Boolean (Read/Write)
Default Value: True
Example:
WebView21.IsGeneralAutoFillEnabled = FalseNote: Use SupportsAutoFillFeatures to check if this feature is supported.
Controls whether pinch gestures control zoom on touch devices.
Type: Boolean (Read/Write)
Default Value: True
Example:
WebView21.IsPinchZoomEnabled = FalseNote: Use SupportsPinchZoomFeatures to check if this feature is supported.
Controls whether swipe gestures control page navigation on touch devices.
Type: Boolean (Read/Write)
Default Value: True
Example:
WebView21.IsSwipeNavigationEnabled = FalseNote: Use SupportsSwipeNavigationFeatures to check if this feature is supported.
Controls whether audio is muted from the webview.
Type: Boolean (Read/Write)
Default Value: False
Example:
WebView21.IsMuted = TrueNote: Use SupportsAudioFeatures to check if this feature is supported.
Indicates whether the WebView2 current document is playing audio.
Type: Boolean (Read-only)
Example:
If WebView21.IsDocumentPlayingAudio Then
Debug.Print "Audio is playing"
End IfNote: Use SupportsAudioFeatures to check if this feature is supported.
Indicates whether WebView2 processing/rendering is suspended.
Type: Boolean (Read-only)
Example:
If WebView21.IsSuspended Then
WebView21.Resume
End IfNote: Use SupportsSuspendResumeFeatures to check if this feature is supported.
Indicates whether the built-in download manager dialog is currently open.
Type: Boolean (Read-only)
Example:
If WebView21.IsDefaultDownloadDialogOpen Then
WebView21.CloseDefaultDownloadDialog
End IfNote: Use SupportsDownloadDialogFeatures to check if this feature is supported.
Environment options configuration object.
Type: WebView2EnvironmentOptions (Read/Write)
Example:
WebView21.EnvironmentOptions.UserDataFolder = "C:\MyAppData"See WebView2EnvironmentOptions.md for detailed documentation.
Controls whether to use deferred event handling.
Type: Boolean (Read/Write)
Default Value: True
Example:
WebView21.UseDeferredEvents = FalseSets additional allowed frame ancestors.
Type: String (Read/Write)
Example:
WebView21.AdditionalAllowedFrameAncestors = "https://trusted-domain.com"The color applied when WebView2 loads.
Type: OLE_COLOR (Read/Write)
Default Value: &Ha0bd95
Example:
WebView21.BackColor = vbWhiteSets the JavaScript call timeout in seconds.
Type: Double (Read/Write)
Example:
WebView21.JsCallTimeOutSeconds = 30The following properties are used to check if specific features are supported:
Indicates whether custom navigation features are supported.
Type: Boolean (Read-only)
Return Condition: CoreWebView2 is not Nothing
Indicates whether suspend/resume features are supported.
Type: Boolean (Read-only)
Return Condition: CoreWebView3 is not Nothing
Indicates whether audio features are supported.
Type: Boolean (Read-only)
Return Condition: CoreWebView8 is not Nothing
Indicates whether download dialog features are supported.
Type: Boolean (Read-only)
Return Condition: CoreWebView9 is not Nothing
Indicates whether task manager features are supported.
Type: Boolean (Read-only)
Return Condition: CoreWebView7 is not Nothing
Indicates whether folder mapping features are supported.
Type: Boolean (Read-only)
Return Condition: CoreWebView5 is not Nothing
Indicates whether PDF features are supported.
Type: Boolean (Read-only)
Return Condition: CoreWebView7 is not Nothing
Indicates whether UserAgent features are supported.
Type: Boolean (Read-only)
Return Condition: Settings2 is not Nothing
Indicates whether accelerator key features are supported.
Type: Boolean (Read-only)
Return Condition: Settings3 is not Nothing
Indicates whether auto-fill features are supported.
Type: Boolean (Read-only)
Return Condition: Settings4 is not Nothing
Indicates whether pinch zoom features are supported.
Type: Boolean (Read-only)
Return Condition: Settings5 is not Nothing
Indicates whether swipe navigation features are supported.
Type: Boolean (Read-only)
Return Condition: Settings6 is not Nothing
If WebView21.SupportsPdfFeatures Then
WebView21.PrintToPdf "C:\output.pdf"
Else
MsgBox "PDF export not supported in this WebView2 version"
End If
If WebView21.SupportsAudioFeatures Then
WebView21.IsMuted = True
End IfWith WebView21
.IsScriptEnabled = True
.AreDefaultContextMenusEnabled = False
.AreDevToolsEnabled = False
.UserAgent = "MyApp/2.0"
.ZoomFactor = 1.0
End With