0

I created a simple content addin for excel and in my js file I have this section of code:

(function () {
    "use strict";

    // The initialize function must be run each time a new page is loaded
    Office.initialize = function (reason) {
         var puppeteer = require('puppeteer');
        $(document).ready(function () {
            $("#compare").click(() {
                  var browser = await puppeteer.launch();
                 } 
            
             });
          };

This doesnt work and I was hoping for puppeteer to work and open a browser. How can I import and use puppeteer in the script?

West
  • 2,350
  • 5
  • 31
  • 67
  • It is not possible to launch puppeteer in the browser. Puppeteer makes use of chromium binary and in the browser you do not have access to file system resp. executables directly. You will have to send a request to your server and let the server open puppeteer. (Puppeteer only works for nodejs but not for javascript ) – Silvan Bregy Jul 17 '22 at 07:11
  • Ah thats a bugger. Ok thanks – West Jul 17 '22 at 09:38
  • The closest thing is an express endpoint that launches puppeteer and use that from excel – pguardiario Jul 18 '22 at 02:01
  • @pguardiario so express will have to be in local computer? – West Jul 18 '22 at 12:17
  • It could be local or remote. – pguardiario Jul 18 '22 at 12:35
  • @pguardiario Thanks for the tip. I just checked but its a lot of trouble so wont go that path – West Jul 18 '22 at 12:52

0 Answers0