VBEval - SetCell

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
snapper1969
Pro Scripter
Posts: 50
Joined: Fri Mar 23, 2007 10:14 am

VBEval - SetCell

Post by snapper1969 » Thu Apr 10, 2008 11:42 am

Hi,

With the code snippet below, what would the VBEval>SetCell params be if I wanted to use theValue?.

I've tried various ways but can't seem to get it to work?.


VBRun>OpenExcelFile,%SCRIPT_DIR%Input.xls
VBEval>GetCell("Sheet3",10,9),Field_1
VBEval>SetCell("Sheet5",20,5,Field_1),nul


Thx,

John

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Thu Apr 10, 2008 11:52 am

VBEval>GetCell("Sheet3",10,9),Field_1
VBEval>SetCell("Sheet5",20,5,"%Field_1%"),nul
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

durexlw
Newbie
Posts: 18
Joined: Mon Mar 17, 2008 1:19 pm

Re: VBEval - SetCell

Post by durexlw » Thu Apr 10, 2008 11:57 am

snapper1969 wrote: With the code snippet below, what would the VBEval>SetCell params be if I wanted to use theValue?.

VBRun>OpenExcelFile,%SCRIPT_DIR%Input.xls
VBEval>GetCell("Sheet3",10,9),Field_1
VBEval>SetCell("Sheet5",20,5,Field_1),nul
For one:
It should be with "%" around the variable "Field_1". For Macro Scheduler "Field_1" without the "%" is just a string, but if you pass to VBScript "Field_1" without the "%", it becomes an invalid string cause VBScript needs the quotes "" around a string.

Like this:

Code: Select all

VBEval>SetCell("Sheet5",20,5,%Field_1%),nul
When it comes to VBScript, values and strings, keep in mind:

Code: Select all

Let>sString=Sometext
VBEval>TestFunction("sString"),r --> passes the string: "sString"
VBEval>TestFunction(%sString%),r --> passes an invalid string: SomeText... invalid to VB, cause it has no quotes "" around it 
VBEval>TestFunction("%sString%"),r --> passes the string: "Sometext"
So if what "Field_1" contains is a string, you may have to put quotes around it to make it valid for VBScript
Like this:

Code: Select all

VBEval>SetCell("Sheet5",20,5,"%Field_1%"),nul
There may be mistakes in the VB parts... make sure with the debugger that "Field_1" actually contains what you like it to contain and keep an eye on it if it contains a string or not, like mtettmar says.
Last edited by durexlw on Thu Apr 10, 2008 12:07 pm, edited 2 times in total.

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Re: VBEval - SetCell

Post by Marcus Tettmar » Thu Apr 10, 2008 12:01 pm

durexlw wrote:
For one:
It should be with "%" around the variable Field_1
And should also include quotes if it is a string. VBScript expects quotes around strings. See my post above.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

snapper1969
Pro Scripter
Posts: 50
Joined: Fri Mar 23, 2007 10:14 am

Thx

Post by snapper1969 » Sat Apr 12, 2008 10:18 am

Thankk you Marcus....works perfectly :lol:


John

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts