Forum Discussion

littleNewton's avatar
littleNewton
Copper Contributor
Jul 22, 2020

VSTO Word Add-in cannot use webBrowser to invoke javascript function

 
VSTO Word Add-in cannot use webBrowser to invoke javascript function

My system version is Windows 10 Pro 2004, and the Visual Studio version is the latest.

I currently have a problem.

  • I created a Word Ribbon menu and then placed a button in it. Click this button and a Form menu will pop up.
  • There are two buttons in the Form menu. The first is to load an HTML page, and the second is to execute some functions in this HTML file.
  • I tested this Form menu in a traditional Win-Form project and it works well.
  • However, when I moved the Form menu into a VSTO C# project, the JavaScript function could not be executed correctly, and the JS function's return value of the function was null.

Does the webBrowser object in VSTO doesn't work because Microsoft don't support?

VSTO: Insert code with highlighting in DOCX file.

Javascript: highlight.js

You can see my project here: 

https://github.com/LittleNewton/Equation_and_Codebox

  • littleNewton's avatar
    littleNewton
    Copper Contributor

    OK, I just know why it cannot.

     

    The webBrowser class is based on IE11 engine, so it would be impossible to run this JS.

     

    I hope the new webView2 release it stable version as soon as possible.

     

Resources