have you made any further progress?
Printable View
have you made any further progress?
webview ALSO can use for web ide
Attachment 188051
i see the positive progress ..
however this code require the (installed) SDK + is limited to x32 due to the usage of the 32 Bit version of WebView2Loader.dll
In case the goal is e.g usage within Office:
* did you check office root folder ?
there is WebView2Host.dll and WebView2Loader.dll (within the correct bitness)
the first offer the entry CreateOfficeWebView2Environment and *Options (to configure the userfolder, and additional parms)
Now this Vtbl approach "just" need to be converted into x64 .. with some (conditional) LongPtr conversions and usage of the both within ".\Microsoft Office\root\Office16"
office64 you can test ,and upload vba code to txt file or save to bas file.
WebView2Loader have x64 version,and vba also can support
https://globalcdn.nuget.org/packages....1774.30.nupkg
(rename to zip file,unzip it)
Microsoft.Web.WebView2.1.0.1774.30\build\native\x64
WebView2Loader.dll
WebView2Loader.dll.lib
@yokesee: I don't know if my answer to your private mail went out. Unfortunately, the number of characters is also limited, so I couldn't write everything there. So here again. I have a test project VBC_UwpWebView.zip on activevb.de in the up/download area. This creates a WebViewControl via WinRT. However, this is still based on the older Edge browser and not on WebView2. The WinRT WebViewControl returns the following UserAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; WebView/3.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36 Edge/18.19045. You were concerned with creating multiple browser instances. All you have to do is make a few small changes to the code.
andCode:Option Explicit
Private IsGetUserAgent As Boolean
' A WebViewControl array would probably be better here.
Private WithEvents WebViewControl As clsWVC
Private WithEvents WebViewControl1 As clsWVC ' <- new
Private WithEvents WebViewControlProcess As clsWVCP
This creates two WebViewControl instances on the same form (hWnd). You can also use a TabControl where you then assign a WebViewControl instance to each tab.Code:Private Sub Form_Load()
Me.ScaleMode = vbPixels
cmdGoBack.Enabled = False
cmdGoForward.Enabled = False
Me.Caption = "WinRT-WebView:"
Call lblInfo.Move(0, Me.ScaleHeight - 15, Me.ScaleWidth, 15)
Set WebViewControlProcess = New clsWVCP
If WebViewControlProcess.Create Then
Set WebViewControl = WebViewControlProcess.CreateWebViewControlAsync(Me.hWnd, NewRect(0, 35, Me.ScaleWidth \ 2, Me.ScaleHeight - 50)) ' <- changed
Set WebViewControl1 = WebViewControlProcess.CreateWebViewControlAsync(Me.hWnd, NewRect(Me.ScaleWidth \ 2, 35, Me.ScaleWidth \ 2, Me.ScaleHeight - 50)) ' <- new
' WebViewControl.Scaling = 0.8 '1 = 100%
Dim UriRuntimeClass As New clsURC
If UriRuntimeClass.CreateUri("https://www.google.de/") Then
Call WebViewControl.Navigate(UriRuntimeClass)
End If
' New
Dim UriRuntimeClass1 As New clsURC
If UriRuntimeClass1.CreateUri("https://www.vbforums.com/") Then
Call WebViewControl1.Navigate(UriRuntimeClass1)
End If
End If
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
WebViewControl1.Closing ' <- new
WebViewControl.Closing
WebViewControlProcess.Terminate
Set WebViewControl1 = Nothing ' <- new
Set WebViewControl = Nothing
Set WebViewControlProcess = Nothing
End Sub
Private Sub Form_Resize()
If Me.WindowState <> vbMinimized Then
Call lblInfo.Move(0, Me.ScaleHeight - 15, Me.ScaleWidth, 15)
WebViewControl.bounds = NewRect(0, 35, Me.ScaleWidth \ 2, Me.ScaleHeight - 50) ' <- changed
WebViewControl1.bounds = NewRect(Me.ScaleWidth \ 2, 35, Me.ScaleWidth \ 2, Me.ScaleHeight - 50) ' <- new
End If
End Sub
Hi,I am running a script which allows me to extract information from a website and view it directly in the Google Chrome console. Now I want to extract said information or store it in a variable but I can't find a way since according to what I have consulted I require one of these 3 options but I don't know how to implement it directly in my code since the function declarations do not appear
this is th script:
script = "var divsListAds = document.querySelectorAll('.mt-ListAds');" & vbCrLf & _
"var hrefArray = [];" & vbCrLf & _
"divsListAds.forEach(function(div) {" & vbCrLf & _
" var enlaces = div.querySelectorAll('a');" & vbCrLf & _
" enlaces.forEach(function(enlace) {" & vbCrLf & _
" hrefArray.push(enlace.getAttribute('href'));" & vbCrLf & _
" });" & vbCrLf & _
"});" & vbCrLf & _
"alert(hrefArray);" & vbCrLf & _
"window.chrome.webview.postMessage(JSON.stringify(hrefArray));"
WV.ExecuteScript script
i need implement this:
PostWebMessageAsJson"
"PostWebMessageAsString"
"add_WebMessageReceived"
If anyone can help me I would greatly appreciate it.
WebView 2 support extends Part of what WebView 2 has been missing is support for extensions, and today I saw on its github that it already supports extensions APIs: experimental extensions APIs Although it is only a preview function at present, the probability of formal inclusion is still relatively large. Try it when you are free.
2023-12-11
https://learn.microsoft.com/en-us/mi...ental-features
CoreWebView2Profile Class:
CoreWebView2Profile.AddBrowserExtensionAsync Method
CoreWebView2Profile.GetBrowserExtensionsAsync Method
I got a hard time to run the codes in excel x64. Can any one provide a x64 version defination of CreateCoreWebView2EnvironmentWithOptions and a sample code to call? And do I need to put the correct loader into the same folder?
Thanks @xiaoyao
The demo works well as a simple application with one form but I found two related problems if the code is used with multiple forms.
1. The form using Webview2 can be opened and used once but if closed and reopened the program crashes. A workaround is to hide the form instead of closing it then show again when required.
2. For the same reason it is impossible to have more than one form using Webview2. No workaround for this.
Hi Xiaoyao
I request you please provide little more details to get results back from executescript .
I tried this solution , but unfortunately it is still crashing .