Hi all,
I'm trying to run some VB Script in a new Excel file.
I have found many tutorials on how to execute a Macro stored within an already existing Excel file, and the following one on Microsoft learn shows how to run some code after opening an already existing file.
Autofit Excel columns using VBScript - Power Automate | Microsoft Learn
In a nutshell what I'm basically trying to do (and failing at) is:
・Launch blank Excel document (stored as ExcelInstance).
・Run VB Script (macro) on that file.

(The resizes are left over from previous experiments to make sure the flow was still working)
Here is the VB Script (mostly based on the above linked help file).
Set objExcel = CreateObject("Excel.Application")
Set objWorkbook = objExcel.Workbooks.Open("%ExcelInstance%")
objExcel.Application.Visible = True
'Selects the specified sheet'
Set objSheet = objWorkbook.Sheets("Sheet1")
objSheet.Range("B4").Select
objSheet.Range("D7").Value = "Test Complete - Macro Worked"
If anyone can point me in the right direction (or let me know that it is not possible), that would be fantastic.
(I'm new to Power Automate, so please be gentle)
*** Edit ***
Ideally I'm looking for a way to avoid saving files.
I have found one way of doing this now, however it causes complications if there is already an instance of Excel running when the flow is started (due to it not specifying which instance it should refer to, it uses the already running Excel rather than the one launched by Power Automate). To which I could add a dialogue box asking the user to close Excel before continuing.
Set objExcel = GetObject(, "Excel.Application")
Set objSheet = objExcel.ActiveWorkbook.ActiveSheet
objExcel.Application.Visible = True
objSheet.Range("D7").Value = "Test Complete - Macro Worked"
Is it possible to use the .Handle property of the Excel Instance generated in Power Automate to specify the instance?
(%ExcelInstance.Handle%)
