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>