Microsoft Excel cannot access the file -PS Script

Sharing a TIP on Scheduling a script that contains excel code.

One of my Script that uses excel was running fine when I was launching it interactively but if scheduled thru

Task scheduler it wasn’t working & threw below errors:

Microsoft Excel cannot access the file

There are several possible reasons:

The file name or path does not exist.
The file is being used by another program.
The workbook you are trying to save has the same name as a currently open
workbook.

On researching there found a simple fix , Just create a directory with name Desktop

C:\Windows\SysWOW64\config\systemprofile\Desktop -(64 Bit OS)

C:\Windows\System32\config\systemprofile\Desktop -(32 bit OS)

After doing this my script started running fine, hope this TIP will assist you if you are in same situation.

Thanks for reading

Sukhija Vikas

http://SysCloudPro.com

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s