A family of Microsoft word processing software products for creating web, email, and print documents.
no worries - thanks macropod.
Cheers
...Steve
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi There,
Does anyone know how the 9 digit unique number used in a Microsoft Word 2003 SP3 cross reference field for a numbered paragraph is derived or calculated, and what VB function I can use to extract or create it?
I use a macro (see below) that creates and inserts a cross reference field. The aim is to quickly create a cross reference from a button rather than go through the tedious "insert>reference>cross reference and select" menus.
The macro tags the reference with a letter "b" followed by an 8 digit random number (eg toggle field codes shows "{ REF b70554752 \n \h }.
The behaviour of this method of cross referencing works well most of the time, but has a couple of annoying flaws.
Firstly, the small risk that a cross reference may be given the same number (ie the random number generator kicscks out the same number twice in a document!). Not really concerned about this as it is very unlikely to occur.
Secondly, and by far the biggest problem, is where a cross reference is created to a numbered paragraph, and the numbered paragraph is subsequently deleted. Instead of the cross reference going to "Error! - Reference Not Found" (as a 'manually inserted' cross reference does), it updates to a different, usually nearby, numbered paragraph.
On comparing the format of a 'manually inserted' cross reference field with my macro generated field, it appears that the "Microsoft" cross reference uses a 9 digit number that is somehow created uniquely based on the paragraph (for example "{ REF _Ref274201605 \n \h }"). This means that if the paragraph referred to is deleted, the reference is no longer valid and the bookmark (correctly) errors ever time.
Does anyone know how the 9 digit unique number used in a Microsoft Word 2003 SP3 cross reference field for a numbered paragraph is derived or calculated, and what VB function I can use to extract or create it?
Many thanks in advance!
Cheers
...Steve
For reference, the current macro is as follows:
___________________
Sub Add_crossRef_to_selected_para()
Dim n As Long
Dim myBookmark As String
n = Int(Rnd() * 100000000) + 1
With ActiveDocument.Bookmarks
.Add Range:=Selection.Range, Name:="b" & n
.DefaultSorting = wdSortByLocation
.ShowHidden = True
End With
Selection.InsertCrossReference ReferenceType:="Bookmark", ReferenceKind:= _
wdNumberNoContext, ReferenceItem:="b" & n, InsertAsHyperlink:=True, _
IncludePosition:=False
End Sub
________________________
A family of Microsoft word processing software products for creating web, email, and print documents.
Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.
no worries - thanks macropod.
Cheers
...Steve