Page 1 of 1

VB-Script = Basic?

Posted: Thu Jul 17, 2014 2:15 pm
by Helix78
I have a VB-Script running from a CMD file now.
The CMD file get started by Robotask.
Can my script be integrated into the Basic Plugin?
> Internal / External Task Script

With Copy / Paste the code does not work.

Code: Select all

Set xl = CreateObject("Excel.Application")
xl.Visible = False  'set to False for production
xl.Workbooks.Open("C:\blp\API\Office Tools\BloombergUI.xla")
Set wb = xl.Workbooks.Open(WScript.Arguments(0))
wscript.sleep 45000
wb.ActiveSheet.UsedRange.Value = wb.ActiveSheet.UsedRange.Value
wb.Save
wb.Close
xl.Quit

Re: VB-Script = Basic?

Posted: Thu Jul 17, 2014 3:11 pm
by Oleg
Basic is not equals to VB script language.
It have some differences.
But the language is very similar

Try this script and read my comments
You should create the variable MyVar in the task and set necessary value to it.
It should work.

Code: Select all

Sub Main
	Set xl = CreateObject("Excel.Application")
	xl.Visible = False  'set to False for production
	xl.Workbooks.Open("C:\blp\API\Office Tools\BloombergUI.xla")

	'Read the value from RoboTask Variable
	MyArgument = RoboTaskApp.ExpandText("{MyVar}")
	Set wb = xl.Workbooks.Open(MyArgument)

	'Use Wait finction instead of
	'wscript.sleep 45000
	Wait 45
	wb.ActiveSheet.UsedRange.Value = wb.ActiveSheet.UsedRange.Value
	wb.Save
	wb.Close
	xl.Quit
End Sub

Re: VB-Script = Basic?

Posted: Mon Jul 21, 2014 2:03 pm
by Helix78
Thank you a lot!
Works perfectly

Re: VB-Script = Basic?

Posted: Tue Jul 22, 2014 2:36 pm
by Helix78
And how to save a value back to a Robotask variable?

Code: Select all

? = wb.Range(B2).Value
Is there any documentation beside the "RoboTaskApp object"? There I didn't find it.

Re: VB-Script = Basic?

Posted: Tue Jul 22, 2014 3:23 pm
by Oleg
see RoboTaskApp.SetUserVariable
Look at RoboTaskApp chapter

the code is:

Code: Select all

RoboTaskApp.SetUserVariable("MyVar",wb.Range(B2).Value)
Pay attention that the value must be a string.
RoboTask keeps user variables as strings.