In the CreateTableOfContents procedure, bookmark names are created by using GetTickCount to create a unique bookmark identifier. This is somewhat dangerous because the time between to GetTickCount calls could be smaller than a tick...(I use a dual core 3GHz computer)
I have the symptom, that identical page numbers are shown for different head lines. They might use the same bookmark identifier.
I would suggest to add a counter to the tick value which is incremented after each call to GetTickCount.
e.g.:
bobj.Name := BookMarkId + IntToStr(GetTickCount + Increment);
Inc(Increment);
or set Increment initally to GetTickCount and only use Increment
or do not use GetTickCount at all and only use the increment value...