Parker Software Ltd Homepage
Forum Home Forum Home > ThinkAutomation Business Process Automation > Scripting
  New Posts New Posts RSS Feed - Cannot get script to open Excel file
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Cannot get script to open Excel file

 Post Reply Post Reply
Typoman View Drop Down
New User
New User

Joined: 17 Aug 2009
Points: 1
Post Options Post Options   Thanks (0) Thanks(0)   Quote Typoman Quote  Post ReplyReply Direct Link To This Post Topic: Cannot get script to open Excel file
    Posted: 17 Aug 2009 at 5:52pm
I need to do a SaveAs on an attachment with Excel so it is in the newest version of Excel. Here is my script:

Sub Main()
    ' commands start here
    WScript.Sleep 10000
    strFile = "c:\reports\wrongformat\content_wrong.xls"
    Set objExcel = CreateObject("Excel.Application")
    strFile1 = "c:\reports\content.xls"

    objExcel.Workbooks.Open strFile
    Set objSheet = objExcel.ActiveWorkbook.Worksheets(1)
    objExcel.Application.DisplayAlerts = False
    objExcel.ActiveWorkbook.SaveAs strFile1, -4143

End Sub

If I run the script manually, it works perfectly. If Email2DB runs the script, it gives this error:

Script error: (&H800a03ec) Microsoft Office Excel cannot access the file 'c:\reports\wrongformat\content_wrong.xls'. 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. Line 11

As you can see, I am working with local directories only, no network locations. I opened the permissions wide up for Everyone. I can't figure out why the script won't work when Email2DB runs it.

Edited by Typoman - 17 Aug 2009 at 6:58pm
Back to Top
Liam View Drop Down
Admin Group
Admin Group

Joined: 29 Jun 2011
Location: Stoke-on-Trent
Points: 253
Post Options Post Options   Thanks (0) Thanks(0)   Quote Liam Quote  Post ReplyReply Direct Link To This Post Posted: 28 Mar 2012 at 8:11pm
The problem here is that the Microsoft Office Scripts can not be called or created via a Service, this is what Email2DB runs as.
When running through the script editor you are running as your user, this is why it goes through fine.
When Email2DB processes an email it is as a service and as such the script cannot be executed and you are presented with the Script Error.
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.05
Copyright ©2001-2016 Web Wiz Ltd.

This page was generated in 0.063 seconds.