Trouble with Excel Get Cells

Discuss RoboTask here
Post Reply
merka
Posts: 2
Joined: Sat Mar 27, 2021 7:46 am

Trouble with Excel Get Cells

Post by merka »

Hi.

I can't figure out how to extract contents of an Excel cell and add it to a variable.

I am doing the following steps,

1. Excel Open Document
2. Excel Get Cells - I added the cell reference and created GLobal and Local variables (I called it {NAME} because the contents of the cell will be a name) but can't get them to work.

I get the errors below,

Invalid variable name
Variable name is empty

Any suggestions as to what I may be doing wrong?

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

Re: Trouble with Excel Get Cells

Post by Oleg »

look at this example how to get cells to variables

Code: Select all

;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
 
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|2091586075
Comment=STRINGLIST
ContinueOnError=INTEGER|0
DisableOnError=INTEGER|0
DoNotStopWhenShutdown=INTEGER|0
ExternalName=STRING|"Task1105"
Hide=INTEGER|0
ID=INTEGER|-12526969
LogOnAsUser=INTEGER|1
Name=STRING|"Get from cells to variables"
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

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

[Actions\Action1\Params]
filename=STRING|"D:\Temp\test.xls"
hide=STRING|"1"
mode=STRING|"0"
tryconnect=STRING|"0"

[Actions\Action2]
ActionID=STRING|"A_EXCEL_GET"
Enabled=INTEGER|-1
Name=STRING|"Excel Get Cells"
Params=FOLDER

[Actions\Action2\Params]
cell00000000=STRING|"c4"
cell00000001=STRING|"c5"
cell00000002=STRING|"c6"
cell00000003=STRING|"c7"
cell00000004=STRING|"c8"
cell00000005=STRING|"c9"
cell00000006=STRING|"c10"
count=STRING|"7"
var00000000=STRING|"var1"
var00000001=STRING|"var2"
var00000002=STRING|"var3"
var00000003=STRING|"var4"
var00000004=STRING|"var5"
var00000005=STRING|"var6"
var00000006=STRING|"var7"
worksheet=STRING|"1"

[Actions\Action3]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|-1
Name=STRING|"Show ""cell values are:"""
Params=FOLDER

[Actions\Action3\Params]
icon=STRING|"1"
msg0=STRING|"cell values are:"
msg1=STRING|"c4 = {var1}"
msg2=STRING|"c5 = {var2}"
msg3=STRING|"c6 = {var3}"
msg4=STRING|"c7 = {var4}"
msg5=STRING|"c8 = {var5}"
msg6=STRING|"c9 = {var6}"
msg7=STRING|"c10 = {var7}"
msgcount=STRING|"8"
playsound=STRING|"0"
showmessage=STRING|"1"
Save the text of the task to a file and use menu Task->Import to import the task into RoboTask.
Then you can see the task in task editor and edit it.
Oleg Yershov
Oleg
Site Admin
Posts: 3000
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: Trouble with Excel Get Cells

Post by Oleg »

This example shows how to put some values to Excel document
Save the text of the task to a file and use menu Task->Import to import the task into RoboTask.

Code: Select all

;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
 
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|2091586075
Comment=STRINGLIST
ContinueOnError=INTEGER|0
DisableOnError=INTEGER|0
DoNotStopWhenShutdown=INTEGER|0
ExternalName=STRING|"Task189"
Hide=INTEGER|0
ID=INTEGER|1436022166
LogOnAsUser=INTEGER|1
Name=STRING|"Put data from text to Excel document"
OnErrorTaskID=INTEGER|-1
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3
UnicodeFormat=INTEGER|1
WriteGeneralLog=INTEGER|0

[Actions]
Action1=FOLDER
Action10=FOLDER
Action11=FOLDER
Action2=FOLDER
Action3=FOLDER
Action4=FOLDER
Action5=FOLDER
Action6=FOLDER
Action7=FOLDER
Action8=FOLDER
Action9=FOLDER

[Actions\Action1]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""exceldoc"" with value ""D:\temp\test.xls"""
Params=FOLDER

[Actions\Action1\Params]
expand=STRING|"0"
varname=STRING|"exceldoc"
varvalue=STRING|"D:\temp\test.xls"

[Actions\Action10]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|-1
Name=STRING|"Show ""Done!"""
Params=FOLDER

[Actions\Action10\Params]
icon=STRING|"1"
msg0=STRING|"Done!"
msg1=STRING|"Click OK to view result!"
msgcount=STRING|"2"
playsound=STRING|"0"
showmessage=STRING|"1"

[Actions\Action11]
ActionID=STRING|"A_GENERAL_RUN_PROG"
Enabled=INTEGER|-1
Name=STRING|"Run ""{ExcelDoc} """
Params=FOLDER

[Actions\Action11\Params]
ifnonzero=STRING|"0"
program=STRING|"{ExcelDoc}"
runas=STRING|"0"
wait=STRING|"0"

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

[Actions\Action2\Params]
filename=STRING|"{ExcelDoc}"
hide=STRING|"0"
mode=STRING|"0"
tryconnect=STRING|"0"

[Actions\Action3]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""NUM"" with value ""1"""
Params=FOLDER

[Actions\Action3\Params]
expand=STRING|"0"
varname=STRING|"NUM"
varvalue=STRING|"1"

[Actions\Action4]
ActionID=STRING|"A_LOOP_TEXT"
Enabled=INTEGER|-1
Name=STRING|"Text Loop"
Params=FOLDER

[Actions\Action4\Params]
destvar=STRING|"LINE"
line0=STRING|"This is"
line1=STRING|"simple text "
line2=STRING|"to copy "
line3=STRING|"it to "
line4=STRING|"Excel document"
linecount=STRING|"5"
sourcetext=STRING|"1"

[Actions\Action5]
ActionID=STRING|"A_EXCEL_SET"
Enabled=INTEGER|-1
Name=STRING|"Excel Set Cells"
Params=FOLDER

[Actions\Action5\Params]
cell00000000=STRING|"R{num}C1"
count=STRING|"1"
setmode=STRING|"0"
var00000000=STRING|"{line}"
worksheet=STRING|"2"

[Actions\Action6]
ActionID=STRING|"A_VARIABLES_INCREMENT"
Enabled=INTEGER|-1
Name=STRING|"Increment variable ""num"""
Params=FOLDER

[Actions\Action6\Params]
incement=STRING|"1"
vaiable=STRING|"num"

[Actions\Action7]
ActionID=STRING|"A_LOOP_END"
Enabled=INTEGER|-1
Name=STRING|"End Loop"

[Actions\Action8]
ActionID=STRING|"A_EXCEL_SAVEDOC"
Enabled=INTEGER|-1
Name=STRING|"Excel Save Document"

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

Oleg Yershov
Post Reply