VB-Script = Basic?

Discuss RoboTask here
Post Reply
Helix78
Posts: 11
Joined: Tue May 27, 2014 9:17 am

VB-Script = Basic?

Post 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
Oleg
Site Admin
Posts: 3202
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: VB-Script = Basic?

Post 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
Oleg Yershov
Helix78
Posts: 11
Joined: Tue May 27, 2014 9:17 am

Re: VB-Script = Basic?

Post by Helix78 »

Thank you a lot!
Works perfectly
Helix78
Posts: 11
Joined: Tue May 27, 2014 9:17 am

Re: VB-Script = Basic?

Post 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.
Oleg
Site Admin
Posts: 3202
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: VB-Script = Basic?

Post 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.
Oleg Yershov
Post Reply