Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I am having a bit of a problem using some common string functions - instr and left, in particular. I am reading in a variable value, and want to find the location of the dash in the string, and then display the first X number of characters in the string, up to the dash.
For example: variable = 334-545
I want the message box to display 334
My code is :
set BandOne = ActiveDocument.Variables("Variable1").getContent
set BandTwo = ActiveDocument.Variables("Variable2").getContent
DashLoc = instr(1, BandOne, "-")
msgbox(left(BandOne, DashLoc))
The code is stopping on the DashLoc location, saying "type mismatch". What am I doing wrong?
Thanks
The functions is fine, just need to handle the variables in a different way
sub inString
dim DashLoc
set BandOne = ActiveDocument.Variables("Variable1")
set BandTwo = ActiveDocument.Variables("Variable2")
DashLoc = instr(1, BandOne.GetContent.String, "-")-1
msgbox(left(BandOne.GetContent.String, DashLoc))
end sub
Hi,
function INSTR not exists, to use ...
subfield(S, ';' ,2) | returns 'cde' if S is 'abc;cde;efg' |
foor more detail see help
good luck, Luis.
Thanks, Luis, but that's not the right function. That is to be used inside either an action or in the load script. I am looking for something that will function in a macro.
The functions is fine, just need to handle the variables in a different way
sub inString
dim DashLoc
set BandOne = ActiveDocument.Variables("Variable1")
set BandTwo = ActiveDocument.Variables("Variable2")
DashLoc = instr(1, BandOne.GetContent.String, "-")-1
msgbox(left(BandOne.GetContent.String, DashLoc))
end sub
Erich... Thank you, thank you! I am having a bit of a hard time getting my head around the syntax here.