Excel automation on Windows Server 2008 x64: solution to SaveAs method problem

April 26th, 2011

A customer of mine uses Lotusscript and the Microsoft Excel object to create Excel spreadsheets with scheduled agents. The code is based on the normal way of creating spreadsheets - e.g.:

Set ExcelApp = CreateObject("Excel.Application")
Set ExcelWorkbook = ExcelApp.Workbooks.Open("C:test.xls")
Set ExcelWorksheet = ExcelWorkbook.Application.Workbooks(1).Worksheets(1)

The scheduled agents worked fine on a Windows Server 2003. The application was then installed on a freshly installed Domino server running on a freshly installed Windows Server 2008 x64 (64 bit) and then the scheduled agents started failing with the following error message: "SaveAs method of Workbook class failed".

After several tries of fixing the code I finally found the simple (but unexpected) solution to the problem: create a folder called "Desktop" in C:\Windows\SysWOW64\config\systemprofile\.

Yes, that's it! just create the folder and then the code starts working again 🙂

Tags: , ,

10 Responses to “Excel automation on Windows Server 2008 x64: solution to SaveAs method problem”

  1. Wright Furman Says:

    I had this same problem but with Domino 64Bit on Windows Server 2008 R2 64 bit with Excel.
    By adding the "Desktop" directory to c:\windows\system32\config\systemprofile, I got the 64
    Bit version of Excell working with Domino 64Bit. I also got Domino 64 bit working with
    the 32 Bit version of Excell with the additon of the "Desktop" directory to the
    c:\windows\SysWOW64\config\systemprofile directory!!

  2. Smita Says:

    The solution mentioned by you has really helped me in solving the same problem. Though I still have a problem that once created the excel does not close or killed and thus execution of my agent also is not completed.

    Following is the code written (this works fine on 2003 server):
    Call gvMSExcelWorkbk.Close(True) '*** Close the excel workboook
    gvMSExcelApp.Quit '*** Close the excel application
    Set gvMSExcelWorkbk = Nothing '*** set variable gvMSExcelWorkbk to blank
    Set gvMSExcelApp = Nothing '*** set variable gvMSExcelApp to blank

    Please let me know if anything else is needed

  3. Balan Says:

    Hi,

    Thanks for the answer it was helpful , tried creating folder as suggested in windows 2008 Server x64 and it worked.

    Could you please throw light on following queries

    1) is there any patch sets or service packs that can fix this issue in windows server 2008 x64

    2) What was the cause for this issue ? is this due to Ms Office or Win Operating system.

  4. Kien Says:

    I found your solution and it worked for me.
    Many thanks Lausten!

  5. Irfan Says:

    Hi,

    Open does not work with the procedure specified.
    How ever on changing the identtiy in COM... it works.
    But changing identiy is not recommened...

    Any other solution...

  6. david Says:

    thnks, it works fine....

  7. david Says:

    it works find!!

  8. Amol Sangle Says:

    It Works Fine, Thanks!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

  9. Tonya Says:

    This is not working for me 🙁 Can someone please help? I did notice that the systemprofile folders have a lock on them. Could that be the problem? I was able to created the Desktop folder but the script still won't run excel.

  10. Per Henrik Lausten Says:

    You probably need admin rights to create that folder.