Question on Selection.InsertCrossReference method in VBA (Word)

Hi, 

We are trying to insert cross reference (xref) programmatically using VBA method. 

(The systems are mostly Word 2010 on Win 7 32bit.)

If we use Selection.InsertCrossReference method, xref is created in the following format:

REF _Ref######### \h \* Charformat

How is the 9-digit number (marked as # above) generated? 

Maybe some calculation using system time?

Since we need to merge many documents into one, we want to make sure that the value is not duplicated even if the xrefs are created by other users.

If it can be duplicated, we will have to come up with a measure to prevent them from being duplicated.

Understanding the logic will be helpful for this as well.

Thank you.

June 25th, 2015 4:15am

Cross-posted at: https://social.msdn.microsoft.com/Forums/office/en-US/7606bbfe-5453-45c7-b62c-f131471da67c/question-on-selectioninsertcrossreference-method-in-vba-word?forum=worddev

For cross-posting etiquette, please read: http://www.excelguru.ca/content.php?184

AFAIK the number is based on an algorithm applied to the current date & time - possibly down to the millisecond. There is thus little likelihood of the same value being generated on different systems.

Free Windows Admin Tool Kit Click here and download it now
June 25th, 2015 6:10am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics