Parker Software Ltd Homepage
Forum Home Forum Home > Email2DB Email Parser > Scripting
  New Posts New Posts RSS Feed: Cannot get script to open Excel file
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Cannot get script to open Excel file

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


Joined: 17 Aug 2009
Posts: 1
Post Options Post Options   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
    objExcel.Application.Quit

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
Avatar

Joined: 29 Jun 2011
Location: Stoke-on-Trent
Posts: 238
Post Options Post Options   Quote Liam Quote  Post ReplyReply Direct Link To This Post Posted: 28 Mar 2012 at 8:11pm
Hello,
 
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

Forum Jump Forum Permissions View Drop Down



This page was generated in 0.156 seconds.
These are the forums for Parker Software, developers of Live Chat Software: WhosOn and Email Automation Software: Email2DB.