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

Gcsingh90

New Member
Joined
Dec 6, 2022
Messages
12
Office Version
  1. 365
Platform
  1. Windows
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 excel file which stays open for some time during which data gets refreshed and before closing the file below MACRO script auto saves the excel file.

macro 1.png


The problem is the below message box needs responding to when script opens the file

error excel m.png


sendkeys.png


Sendkey works fine to tackle the above. However, there is a problem

The code invokes a method using the wscript.shell object and works fine when we 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.


prob.png


However, I have been told 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 resolve 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.

Using excel 365 for enterprise

Thanks
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.

Forum statistics

Threads
1,215,069
Messages
6,122,953
Members
449,095
Latest member
nmaske

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top