Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi Guys
I have the following macrocode which returns activated objectIDs.
Sub getActiveObjectID
set s=ActiveDocument.ActiveSheet
objs=s.GetSheetObjects
for i=lbound(objs) to ubound(objs)
if objs(i).IsActive then
var = right(objs(i).GetObjectId,4)
msgbox(var)
end if
next
End Sub
For example If I have CH01, CH02 and TX01 activated how can i store this as a string in a variable while executing the macro, like:
msgBox(Variable) = "CH01","CH02","TX01"
Any Ideas?
Hi,
Sub getActiveObjectID
set s=ActiveDocument.ActiveSheet
objs=s.GetSheetObjects
for i=lbound(objs) to ubound(objs)
if objs(i).IsActive then
var = var & chr(34)& right(objs(i).GetObjectId,4) & chr(34) & chr(44)
msgbox(var)
end if
next
set v = ActiveDocument.Variables("MyVar")
v.SetContent var,true
End Sub
Hi,
Sub getActiveObjectID
set s=ActiveDocument.ActiveSheet
objs=s.GetSheetObjects
for i=lbound(objs) to ubound(objs)
if objs(i).IsActive then
var = right(objs(i).GetObjectId,4)
msgbox(var)
end if
next
set v = ActiveDocument.Variables("MyVar")
v.SetContent var,true
End Sub
hi fer fer,
thank you for your answer
your piece of code only adds the last marked object to the variable.
In the below example i expect the output for MyVar to be :
MyVar = TX05,TX06,TX07
Hi,
Sub getActiveObjectID
set s=ActiveDocument.ActiveSheet
objs=s.GetSheetObjects
for i=lbound(objs) to ubound(objs)
if objs(i).IsActive then
var = var & chr(34)& right(objs(i).GetObjectId,4) & chr(34) & chr(44)
msgbox(var)
end if
next
set v = ActiveDocument.Variables("MyVar")
v.SetContent var,true
End Sub
that works.
thank you very much!