Open method of Workbooks class failed

Discuss RoboTask here
Post Reply
wbyford
Posts: 10
Joined: Thu Jan 11, 2018 5:29 pm

Open method of Workbooks class failed

Post by wbyford »

We are moving our processes from a Windows 2008 R2 server to a Windows 2016 server. We currently have RoboTask running as a service on the 2008 server. I am in the process of moving those tasks to RoboTask running as a service on the 2016 server. Most tasks ported over without issue. But I have 2 tasks that open an Excel workbook then save it as a .csv file. On the new server, I keep getting an error: 'Open method of Workbooks failed'. It works fine from the desktop app but fails when run from the service.

Any ideas as to why this is failing? Could it be an issue of permissions?
wbyford
Posts: 10
Joined: Thu Jan 11, 2018 5:29 pm

Re: Open method of Workbooks class failed

Post by wbyford »

Here is the code I am using.

Code: Select all

;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
 
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|1018417490
Comment=STRINGLIST
ContinueOnError=INTEGER|0
DoNotStopWhenShutdown=INTEGER|0
ExternalName=STRING|"Task1"
Hide=INTEGER|0
ID=INTEGER|-1066130470
LogOnAsUser=INTEGER|1
Name=STRING|"Save Excel file as csv"
OnErrorTaskID=INTEGER|-1
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3
UnicodeFormat=INTEGER|1
WriteGeneralLog=INTEGER|0

[Actions]
Action1=FOLDER
Action2=FOLDER
Action3=FOLDER
Action4=FOLDER

[Actions\Action1]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""YMD_CURRENTDATE"" with value ""{DateTimeToFormat({Date},yyyymmdd)}"""
Params=FOLDER

[Actions\Action1\Params]
=STRING|""
expand=STRING|"1"
varname=STRING|"YMD_CURRENTDATE"
varvalue=STRING|"{DateTimeToFormat({Date},yyyymmdd)}"

[Actions\Action2]
ActionID=STRING|"A_EXCEL_OPEN"
Enabled=INTEGER|-1
Name=STRING|"Excel Open Document "
Params=FOLDER

[Actions\Action2\Params]
filename=STRING|"C:\temp\test.xlsx"
hide=STRING|"1"
mode=STRING|"0"

[Actions\Action3]
ActionID=STRING|"A_EXCEL_SAVEDOCAS"
Enabled=INTEGER|-1
Name=STRING|"Excel save as CSV into the file ""test_{YMD_CURRENTDATE}"""
Params=FOLDER

[Actions\Action3\Params]
filename=STRING|"c:\temp\test_{YMD_CURRENTDATE}"
format=STRING|"1"
ifexists=STRING|"1"

[Actions\Action4]
ActionID=STRING|"A_EXCEL_CLOSE"
Enabled=INTEGER|-1
Name=STRING|"Excel Close"

Oleg
Site Admin
Posts: 3000
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: Open method of Workbooks class failed

Post by Oleg »

MS Excel™ requires some settings of user environment.
When you install MS office you have to make first start of application (Excel) and make some initial configuration in the user session.
If you want to to start Excel in service mode (Excel actions use MS Excel application) then it work in separate SYSTEM session.

Window 2012 allows to interact with SYSTEM session (interactive services or launched applications in SYSTEM session). So you can make initial settings for Excel.
But Windows 10 and Windows 2016 locks keyboard and mouse at all when you enter into SYSTEM session. You can change nothing and you can see the screen only.
It seems this is another one restriction of system security.
Oleg Yershov
wbyford
Posts: 10
Joined: Thu Jan 11, 2018 5:29 pm

Re: Open method of Workbooks class failed

Post by wbyford »

Thank you, Oleg! That helped. I had to add the folders I was referencing to the Trusted Locations. This resolved my issue.
Post Reply