Page 1 of 1

Variables and Basic

Posted: Tue Aug 16, 2011 11:56 am
by domalino
hi, im looking to get robotask after finding automate too unreliable, but i need to know how to do this task, as i am having no luck doing it on my trial copy.it goes like this1) create variable strfile2) loop  3)move/copy file  4) internal basic script  5) move copy file6 end loopthe problem is that i store the names of the files i move in the "strfile" variable but in the basic script i cant call on this variable to open the file, as it says it does not recognise it as a variable (the error log reads, "was expecting a variable") here is the basic script if it helps:

Code: Select all

Sub Main<br style="font-family: Courier New,Courier,mono; font-style: italic;"><br style="font-family: Courier New,Courier,mono; font-style: italic;">    Dim objExcel As Object<br style="font-family: Courier New,Courier,mono; font-style: italic;">    Dim wbkExcel1 As Object<br style="font-family: Courier New,Courier,mono; font-style: italic;">     Set objExcel = CreateObject( "Excel.Application")<br style="font-family: Courier New,Courier,mono; font-style: italic;"><br style="font-family: Courier New,Courier,mono; font-style: italic;">       objExcel.Visible = False<br style="font-family: Courier New,Courier,mono; font-style: italic;">    objExcel.Workbooks.Open Filename:="\\Server-1\production_share\Test Auto Bucket\Automates Tasks and Other Stuff\Macro Storage\PERSONAL.XLSB"<br style="font-family: Courier New,Courier,mono; font-style: italic;">    objExcel.Workbooks.Open Filename:= %STRFILE%<br style="font-family: Courier New,Courier,mono; font-style: italic;"><br style="font-family: Courier New,Courier,mono; font-style: italic;">    objExcel.Run "PERSONAL.xlsb!Lighthouse_Converter"<br style="font-family: Courier New,Courier,mono; font-style: italic;">    objExcel.Run "PERSONAL.xlsb!validateLighthouseFormat"<br style="font-family: Courier New,Courier,mono; font-style: italic;"><br style="font-family: Courier New,Courier,mono; font-style: italic;">    Set wbkExcel1 = objExcel.ActiveWorkbook<br style="font-family: Courier New,Courier,mono; font-style: italic;">    'Set wbkExcel1 = objExcel.ActiveWorkbook.Worksheets(1)<br style="font-family: Courier New,Courier,mono; font-style: italic;">    wbkExcel1.Close SaveChanges:= True<br style="font-family: Courier New,Courier,mono; font-style: italic;"><br style="font-family: Courier New,Courier,mono; font-style: italic;"><br style="font-family: Courier New,Courier,mono; font-style: italic;">    objExcel.ActiveWorkbook.Close False<br style="font-family: Courier New,Courier,mono; font-style: italic;"><br style="font-family: Courier New,Courier,mono; font-style: italic;">    objExcel.Quit<br style="font-family: Courier New,Courier,mono; font-style: italic;"><br style="font-family: Courier New,Courier,mono; font-style: italic;">End Sub<br>
Any help would be much appreciated! thanks,domalino

Variables and Basic

Posted: Tue Aug 30, 2011 6:30 am
by domalino
bump.

Variables and Basic

Posted: Tue Aug 30, 2011 7:11 am
by Oleg
You can use expression
RoboTaskApp.ExpandText("{strfile}")
in order to retrieve task variable (local or global)

Also see small example below:

Code: Select all

[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|1997303036
Comment=STRINGLIST
ContinueOnError=INTEGER|0
ExternalName=STRING|"Task56"
Hide=INTEGER|0
ID=INTEGER|54919876
LocalVariables=STRING|"strfile"
LogOnAsUser=INTEGER|1
Name=STRING|"Using task variables"
OnErrorTaskID=INTEGER|0
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3
WriteGeneralLog=INTEGER|0

[Actions]
Action1=FOLDER
Action2=FOLDER

[Actions\Action1]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""STRFILE"" with value ""c:\temp\myfile.txt"""
Params=FOLDER

[Actions\Action1\Params]
expand=STRING|"0"
varname=STRING|"STRFILE"
varvalue=STRING|"c:\temp\myfile.txt"

[Actions\Action2]
ActionID=STRING|"BASIC_SCRIPT"
Enabled=INTEGER|-1
Name=STRING|"Internal basic script"
Params=FOLDER

[Actions\Action2\Params]
line00000=STRING|"Sub Main"
line00001=STRING|"Dim BasicStrFile"
line00003=STRING|"BasicStrFile = RoboTaskApp.ExpandText(""{strfile}"")"
line00005=STRING|"MsgBox(BasicStrFile)"
line00007=STRING|"End Sub"
linecount=STRING|"8"
source=STRING|"0"