Can't pass a string with double quote ["] to VBScript

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
myer75
Newbie
Posts: 5
Joined: Thu Jan 06, 2005 4:52 pm

Can't pass a string with double quote ["] to VBScript

Post by myer75 » Sat Jan 08, 2005 10:43 am

I tried to trim the leading and trailing text and it works fine until I got the text with double quote ["].
How can we replace it with different character or delete it before call a VBScript functions related to string?
Please help me since I stuck from here and can't poke data from excel to an array.
Any help will be appreciated. Thank you so much in advance.
I post the code below to let you look on your computer to see what I mean.

VBSTART
Set objExcel = CreateObject("Excel.Application")
objExcel.Workbooks.Add
objExcel.Visible = True
VBEND
Wait>1
Press CTRL
Press Home
Release CTRL
Wait>0.5
Press Down
' Enter the val " ABC". The leading space is 2 spaces.
Send> This string has double quote as " that I can not trim it
Press Enter
' Move up to cell(2,1)
Press Up
Wait>0.5
Press CTRL
send>c
Release CTRL
Wait>0.5
GetClipBoard>val
Wait>0.5
MessageModal>val
' The result should be ABC without leading space
GetClipBoard>val
Length>val,lv
Let>lv=lv-2
MidStr>val,1,lv,val
VBEval>Trim("%val%"),val
MessageModal>val
Best regards,
Have a great day
Richard Myer, sale rep.

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Sat Jan 08, 2005 11:43 am

This little trick will convert a string surrounded by quotes to one without them:

Let>Val="ABC"
VBEval>%val%,val
MJT Net Support
[email protected]

myer75
Newbie
Posts: 5
Joined: Thu Jan 06, 2005 4:52 pm

Post by myer75 » Mon Jan 10, 2005 3:12 am

I am sorry not to make myself clear.
I have a Product Title in the excel cell from cutomer that I can't alter it and I can't tell the customer use inch instead of ".
Example: NEW Craftsman Microtork 3/8" Torque Wrench

When I try to copy this title from Excel cell to the clipboard and then assign to a variable, after that, I call a Trim function from VBScript. It seems it doesn't like it.
It keep saying syntax error. It might confuse with the string double quote
" NEW Craftsman Microtork 3/8" Torque Wrench". Since it has 3 double quotes.

How can I remove the single quote after 3/8 before passing to the VBScript function?

Below it the first code i rewrited it to make mysel clear. It gave me the error,
The same second code but I deleted " in Product Title and it worked well.

First MS Script

VBSTART
Set objExcel = CreateObject("Excel.Application")
objExcel.Workbooks.Add
objExcel.Visible = True
VBEND
Let>SK_DELAY=10
Wait>1
Press CTRL
Press Home
Release CTRL
Wait>0.5
Press Down
' Product Title: NEW Craftsman Microtork 3/8" Torque Wrench
Send> NEW Craftsman Microtork 3/8" Torque Wrench
Press Enter
' Move up to cell(2,1)
Press Up
Wait>0.5
Press CTRL
send>c
Release CTRL
Wait>0.5
GetClipBoard>val
Wait>0.5
MessageModal>val
' The result should be:NEW Craftsman Microtork 3/8" Torque Wrench
GetClipBoard>val
Length>val,lv
Let>lv=lv-2
MidStr>val,1,lv,val
VBEval>Trim("%val%"),val
MessageModal>val

Second MS Script

VBSTART
Set objExcel = CreateObject("Excel.Application")
objExcel.Workbooks.Add
objExcel.Visible = True
VBEND
Let>SK_DELAY=10
Wait>1
Press CTRL
Press Home
Release CTRL
Wait>0.5
Press Down
' Product Title: NEW Craftsman Microtork 3/8" Torque Wrench
Send> NEW Craftsman Microtork 3/8 Torque Wrench
Press Enter
' Move up to cell(2,1)
Press Up
Wait>0.5
Press CTRL
send>c
Release CTRL
Wait>0.5
GetClipBoard>val
Wait>0.5
MessageModal>val
' The result should be:NEW Craftsman Microtork 3/8" Torque Wrench
GetClipBoard>val
Length>val,lv
Let>lv=lv-2
MidStr>val,1,lv,val
VBEval>Trim("%val%"),val
MessageModal>val
I
Best regards,
Have a great day
Richard Myer, sale rep.

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