Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi all,
I have this problem:
I have a database with many fields,one of them is CUSTOMER ( around 1000 rows).
I have a Excel file with 100 customers , I copy and paste all this customers in an input field.
And the question is : How i can add this customers (from the input field) to the current selection?
Thanks
Hi,
Here is a macro I used for such task:
sub CustomerListOnChange
set doc = ActiveDocument
set obj = doc.Fields("CUSTOMER")
set input = ActiveDocument.Variables("CustomerList")
varArray = input.GetContent.String
'replace line breaks with commas
if trim(varArray) <> "" then
varArray = Replace(varArray,chr(10),",")
varArray = Replace(varArray,chr(13),",")
varValue = split(varArray,",")
'Get a list of values already included in the current selection
set varSelection = obj.GetSelectedValues
j = varSelection.Count
'Add values to the list of selected values
for i=lbound(varValue) to ubound(varValue)
if varValue(i) <> "" then
varSelection.Add
varSelection(j).Text = varValue(i)
varSelection(j).IsNumeric = False
j = j+1
end if
next
'Make a new selection with the extended value list
obj.SelectValues varSelection, false, true
end if
end sub
The macro should be attached to the CustomerList variable OnChange event. CustomerList variable should be linked to the input field in your application.
/Masha
I think i need a Macro but which one?
Hi,
Here is a macro I used for such task:
sub CustomerListOnChange
set doc = ActiveDocument
set obj = doc.Fields("CUSTOMER")
set input = ActiveDocument.Variables("CustomerList")
varArray = input.GetContent.String
'replace line breaks with commas
if trim(varArray) <> "" then
varArray = Replace(varArray,chr(10),",")
varArray = Replace(varArray,chr(13),",")
varValue = split(varArray,",")
'Get a list of values already included in the current selection
set varSelection = obj.GetSelectedValues
j = varSelection.Count
'Add values to the list of selected values
for i=lbound(varValue) to ubound(varValue)
if varValue(i) <> "" then
varSelection.Add
varSelection(j).Text = varValue(i)
varSelection(j).IsNumeric = False
j = j+1
end if
next
'Make a new selection with the extended value list
obj.SelectValues varSelection, false, true
end if
end sub
The macro should be attached to the CustomerList variable OnChange event. CustomerList variable should be linked to the input field in your application.
/Masha
Thx Masha
Could someone attach a qvw with this example working?
DA