Gotcha! – Office 2007 Automation with Powershell in Windows 2008

It seems MS has changed the game again on Office automations with Office 2007 and Windows 2008 and/or Windows 7 and Powershell scripts. I do quite a bit of Powershell scripting and found that after upgrading my script host to 2008 R2, my scripts scheduled in Task Manager no longer worked. I pulled out my hair for a few days trying all kinds of different things – changing paths, permissions, syntax – you name it, I tried it. I kept getting this error message –

Exception calling “SaveAs” with “1” argument(s): “SaveAs method of Workbook class failed”

After Googling for the hundreth time or so, I finally stumbled across this post on the Social MSDN Forums. I could not believe it that when I simply added a folder to the server, it all worked! This is the folder you need to add (Thank you H Ogawa for your posting!) –
・Windows 2008 Server x64
Please make this folder.
C:WindowsSysWOW64configsystemprofileDesktop

・Windows 2008 Server x86
Please make this folder.
C:WindowsSystem32configsystemprofileDesktop

Frustrating, but fixed!

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.