1 Reply Latest reply: Sep 28, 2012 6:43 AM by arnes beganovic

# Compare two bookmarks

Hi,

is it possible to compare one field with itself based on two different states of selections. I have one bookmark that gives me the part list: A,B,C,D,E,F. Second bookmark gives me: B,C,D,G. Can I compare somehow theese two bookmarks to get final list: A,E,F (only values that are in bookmark one but not in bookmark two)? I need only list from this field.

I feel that macro can solve this problem but I do not have that much knowledge. I appreciate any help.

• ###### Re: Compare two bookmarks

Hi again,

yes it is possible. It took me some time to fix all variables and with help topics I was able to make this code. Thats why I want to share it. I do not know if it is optimal solution, but it works and it is fast enough.

sub ExtractParts

'Field to filter

set araj=ActiveDocument.Fields("G_VCC")

'Activate first bookmark

ActiveDocument.RecallDocBookmark "Set1"

'Take possible values from field G_VCC into array

SET PrvaLista = araj.GetPossibleValues

'Activate second bookmark

ActiveDocument.RecallDocBookmark "Set2"

'ake possible values from field G_VCC into array

SET DrugaLista = araj.GetPossibleValues

'Count length of both arrays

brojac1 = PrvaLista.Count

brojac2 = DrugaLista.Count

'loop throught both arrays. Goal is to check every line from first array with every line from second and to extract those that are same.

for i=0 to brojac1 - 1

'Set variable with "i" line from array1

set VCC1 = PrvaLista(i)

'Loop through second array

for j = 0 to brojac2-1

'Set variable with "j" line from array2

set VCC2 = DrugaLista(j)

'If value from first array is equal to value from second array

if VCC1.Text = VCC2.Text then

'Then result is previous result;NewVariable

Rezultat = Rezultat & PrvaLista(i).text & "; "

end if

next

next

'At the end, result variable "Rezultat" is placed in previously created variable "Probna" in front end. There is textbox on frontend that takes variable "Probna"

ActiveDocument.Variables("Probna").SetContent Rezultat, true

end sub

Question 2: How to format data in textbox. Right now I get a list with Part;Part;Part... Is it possible to get:

Part;

Part;

Part;

.

.

.

But this issue is solved Thank you all, because I used other  questions and answers to get this done.