Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago

Power shell and [Expression.Error] 2 arguments were passed to a function which expects 1

Trying to create a automation flow for a scheduled refresh where data is getting fetched from Sharepoint Lists and later unpivoted in Power Query (which is working fine). In order to refresh the excel file, shell script opens the file and stays open for some time during which data gets refreshed and upon closing below MACRO script saves the excel file.

 

The problem is that below message box needs responding to


The code invokes a method using the wscript.shell object and works fine when you are logged into the system. Unfortunately we need to this run on an unattended system. However due to the security policy the screen lock kicks in. When that happens it is no longer possible to invoke the wscript.shell object. Below link. 

wsh - VBScript not working when PC is locked - Stack Overflow

 

 

However, the commands to open the Excel file and then do a graceful shutdown using macro do not have this limitation

Can you please guide how to reolve this, perhaps any changes in Macros also to see what is causing the error message to appear. If that can be removed the automation should work fine i guess.

I am beginner trying to find the solution.

Thanks

2 Replies