Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Good day,
I'm just wondering can i pass the values of a list box to an array then make a loop statement so that i dont have to select the field value one by one.
Hope you can help me on this...
hi,
You can do it at macro level.
rem ** show each possible value in list box **
set LB = ActiveDocument.GetSheetObject("LB01")
boxvalues=LB.GetPossibleValues
for i = lbound(boxvalues) to ubound(boxvalues)
msgbox(boxvalues(i))
next
what if i want to pass it to a variable instead of a message box..??
cause i will use it in my set analysis..thanks!
HI,
add this code instead of message box
set v = ActiveDocument.Variables("Variable1") // you can write this code before for loop
v.SetContent "123",true /// inside for loop
Instead of 123 add box value
when i use a text object to check if the variable got all the values in the list box, the text object shows " - "
text box and variable cant store array value it can show only single value
if you want to store it in a variable and use it in set analysis then you should convert data into string
a= "BrandA",BrandB",BrandC"
us this expression
var = & """ & var & boxvalue & """ this should be written inside for loop
and after next
v.SetContent var ,true
I encountered a syntax error on this part: var = & """ & var & BoxValue & """
can you give me the whole process cause i'm not that familiar with macros..thanks!
Hi,
I'd rather use the concat() function (use first ina textbox to see if this does):
=chr(39) & Concat(DISTINCT Brand, chr(39) & ',' & chr(39) ) & chr(39)
Now in the load script you can use a for each loop
Brands:LOAD * INLINE [BrandBrandABrandVBrandFBrandG]; BrandArrayTable: // Building the array LOAD RowNo() AS No, CONCAT(DISTINCT Brand, chr(39) & ', ' & chr(39)) AS BrandArrayRESIDENT Brands; LET vAllBrands = chr(39) & Peek('BrandArray') & chr(39); FOR EACH vBrand IN $(vAllBrands) TRACE $(vBrand);NEXT