0

I have no experience with JScript or javascript, but I had an issue that I thought might be a quick solution with what was available online. Ultimately I am trying to create a macro with javascript, but the rest of it is in VBA7. I found a dated article for embedding javascript into wsc for vba: WSC for Excel Macro

Attempting to use visual studio add in projects proved to be beyond my expertise and I was hoping to avoid studying a new language.

I'm getting an error that says "[31,15] Expected ;"

Will this work? Is there a better way to accomplish this? I imagine there might be multiple errors in my code.

<?xml version="1.0"?>
<package>
<component id="RangeDelete">
  <comment>
    JS delete function
  </comment>
<?component error="true" debug="true"?>
<registration
  description="WSC Component for cell delete"
  progid="RangeDelete"
  version="1.00"
  remotable="False">
  <script language="VBScript">
  <![CDATA[
    strComponent = "Deleting Range of cells"
    Function Register
      MsgBox strComponent & " - registered."
    End Function
    Function Unregister
      MsgBox strComponent & " - unregistered."
    End Function
  ]]>
  </script>
</registration>
<public>
  <method name="DeleteCells">
  </method>
</public>
<script language="Javascript">
<![CDATA[
        await run(async (context) =>      //here is where I get the error "[31,15] Expected ;" 
        let range = context.workbook.getSelectedRange();
        range.delete(Excel.DeleteShiftDirection.up);
        await context.sync();
        });
]]>
</script>
</component>
</package>
  • I think if your browser is old enough to support VBScript, it’s very far away from supporting arrow function syntax and even further away from supporting `async`–`await`. Which browser are you running this in? – Sebastian Simon Feb 09 '23 at 13:22
  • @SebastianSimon It doesn't use a browser. It runs as a registered com file "WSC" which gets called by excel in a VBA script. I may be doing this entirely wrong. I know python and some HTML, but that's it. – user14894283 Feb 10 '23 at 20:14

0 Answers0