help with cross-reference

N

nerfemail

Hi,

I'm working on a big document and I need to know if there is a faster way to
insert cross-reference links.

On every chapter (H1), I insert a list of of sub-headers (H2). It looks like
this:
-----------------------------
1. Chapter One
- Section 1.1 "title" on page 99
-----------------------------

What I am currently doing is, "insert > reference > cross-reference >".
Then select the target heading, with "heading number", then the same for
header text and header page. This takes a long time, as i have to scroll the
list of headers (long) for each of the three components of each reference.

Is there any way of inserting all three components with a single click (or
faster than what I am doing now?

Basically, I would like to say:
- insert reference link to heading 1.1 and it would automatically output "-
Section 1.1 "title" on page 99", where "1.1" is the header number, "title" is
the title text and "99" is the header page number

thank you for your help.
 
S

Stefan Blom

Unfortunately, there is no way to cross-reference heading text, heading number,
and page number without inserting three separate cross-references.
 
D

Doug Robbins - Word MVP

After inserting a cross reference to the paragraph number, select it and
then run a macro containing the following code

Dim fcode As Range
Dim ftext As String
Set fcode = Selection.Fields(1).Code
ftext = Replace(fcode.Text, "\r", "")
Selection.InsertBefore "- Section "
Selection.InsertAfter " " & Chr(34)
Selection.Collapse wdCollapseEnd
ActiveDocument.Fields.Add Selection.Range, wdFieldEmpty, ftext
Selection.Collapse wdCollapseEnd
Selection.InsertAfter Chr(34) & " on page "
Selection.Collapse wdCollapseEnd
ActiveDocument.Fields.Add Selection.Range, wdFieldEmpty, Replace(ftext,
"REF", "PAGEREF")


and if the cross reference displayed 1,1, you would get

- Section 1.1 "[Heading 2 text]" on page [page number]

See the following page of fellow MVP Graham Mayor's website if you do not
know what to do with the above code:

http://www.gmayor.com/installing_macro.htm

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 
S

Stefan Blom

Clever!

--
Stefan Blom
Microsoft Word MVP



Doug Robbins - Word MVP said:
After inserting a cross reference to the paragraph number, select it and then
run a macro containing the following code

Dim fcode As Range
Dim ftext As String
Set fcode = Selection.Fields(1).Code
ftext = Replace(fcode.Text, "\r", "")
Selection.InsertBefore "- Section "
Selection.InsertAfter " " & Chr(34)
Selection.Collapse wdCollapseEnd
ActiveDocument.Fields.Add Selection.Range, wdFieldEmpty, ftext
Selection.Collapse wdCollapseEnd
Selection.InsertAfter Chr(34) & " on page "
Selection.Collapse wdCollapseEnd
ActiveDocument.Fields.Add Selection.Range, wdFieldEmpty, Replace(ftext, "REF",
"PAGEREF")


and if the cross reference displayed 1,1, you would get

- Section 1.1 "[Heading 2 text]" on page [page number]

See the following page of fellow MVP Graham Mayor's website if you do not know
what to do with the above code:

http://www.gmayor.com/installing_macro.htm

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com

Hi,

I'm working on a big document and I need to know if there is a faster way to
insert cross-reference links.

On every chapter (H1), I insert a list of of sub-headers (H2). It looks like
this:
-----------------------------
1. Chapter One
- Section 1.1 "title" on page 99
-----------------------------

What I am currently doing is, "insert > reference > cross-reference >".
Then select the target heading, with "heading number", then the same for
header text and header page. This takes a long time, as i have to scroll the
list of headers (long) for each of the three components of each reference.

Is there any way of inserting all three components with a single click (or
faster than what I am doing now?

Basically, I would like to say:
- insert reference link to heading 1.1 and it would automatically output "-
Section 1.1 "title" on page 99", where "1.1" is the header number, "title" is
the title text and "99" is the header page number

thank you for your help.
 
S

Sue Stevens

Hi,

found your macro - thank you, thank you. hoping you can help to modify it slightly to accommodate my situation where my page numbers also reference the chapter number? For example, when I use your macro to build a 3 part cross reference to a section which is in Chapter 6 on page 39, the built cross reference only references page 39, whereas the actual page number in my document is 6-39. Sorry, I'm just not familiar enough with macros to make this adjustment myself. I tried to find a word field type for chapter reference but there doesn't seem to be one? With thanks in advance.
Hi,

I am working on a big document and I need to know if there is a faster way to
insert cross-reference links.

On every chapter (H1), I insert a list of of sub-headers (H2). It looks like
this:
-----------------------------
1. Chapter One
- Section 1.1 "title" on page 99
-----------------------------

What I am currently doing is, "insert > reference > cross-reference >".
Then select the target heading, with "heading number", then the same for
header text and header page. This takes a long time, as i have to scroll the
list of headers (long) for each of the three components of each reference.

Is there any way of inserting all three components with a single click (or
faster than what I am doing now?

Basically, I would like to say:
- insert reference link to heading 1.1 and it would automatically output "-
Section 1.1 "title" on page 99", where "1.1" is the header number, "title" is
the title text and "99" is the header page number

thank you for your help.
On Friday, May 28, 2010 1:55 PM Stefan Blom wrote:
Unfortunately, there is no way to cross-reference heading text, heading number,
and page number without inserting three separate cross-references.
On Friday, May 28, 2010 7:58 PM Doug Robbins - Word MVP wrote:
After inserting a cross reference to the paragraph number, select it and
then run a macro containing the following code

Dim fcode As Range
Dim ftext As String
Set fcode = Selection.Fields(1).Code
ftext = Replace(fcode.Text, "\r", "")
Selection.InsertBefore "- Section "
Selection.InsertAfter " " & Chr(34)
Selection.Collapse wdCollapseEnd
ActiveDocument.Fields.Add Selection.Range, wdFieldEmpty, ftext
Selection.Collapse wdCollapseEnd
Selection.InsertAfter Chr(34) & " on page "
Selection.Collapse wdCollapseEnd
ActiveDocument.Fields.Add Selection.Range, wdFieldEmpty, Replace(ftext,
"REF", "PAGEREF")


and if the cross reference displayed 1,1, you would get

- Section 1.1 "[Heading 2 text]" on page [page number]

See the following page of fellow MVP Graham Mayor's website if you do not
know what to do with the above code:

http://www.gmayor.com/installing_macro.htm

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 
S

Stefan Blom

If you use the built-in headings and set up chapter/page numbering properly as discussed in the article at http://word.mvps.org/faqs/numbering/chapternumber.htm, the heading number will be automatically added as you insert cross-references to page numbers.

-- 
Stefan Blom
Microsoft Word MVP




---------------------------------------------
"Sue Stevens" wrote in message
Hi,

found your macro - thank you, thank you. hoping you can help to modify it slightly to accommodate my situation where my page numbers also reference the chapter number? For example, when I use your macro to build a 3 part cross reference to a section which is in Chapter 6 on page 39, the built cross reference only references page 39, whereas the actual page number in my document is 6-39. Sorry, I'm just not familiar enough with macros to make this adjustment myself. I tried to find a word field type for chapter reference but there doesn't seem to be one? With thanks in advance.
Hi,

I am working on a big document and I need to know if there is a faster way to
insert cross-reference links.

On every chapter (H1), I insert a list of of sub-headers (H2). It looks like
this:
-----------------------------
1. Chapter One
- Section 1.1 "title" on page 99
-----------------------------

What I am currently doing is, "insert > reference > cross-reference >".
Then select the target heading, with "heading number", then the same for
header text and header page. This takes a long time, as i have to scroll the
list of headers (long) for each of the three components of each reference.

Is there any way of inserting all three components with a single click (or
faster than what I am doing now?

Basically, I would like to say:
- insert reference link to heading 1.1 and it would automatically output "-
Section 1.1 "title" on page 99", where "1.1" is the header number, "title" is
the title text and "99" is the header page number

thank you for your help.
On Friday, May 28, 2010 1:55 PM Stefan Blom wrote:
Unfortunately, there is no way to cross-reference heading text, heading number,
and page number without inserting three separate cross-references.
On Friday, May 28, 2010 7:58 PM Doug Robbins - Word MVP wrote:
After inserting a cross reference to the paragraph number, select it and
then run a macro containing the following code

Dim fcode As Range
Dim ftext As String
Set fcode = Selection.Fields(1).Code
ftext = Replace(fcode.Text, "\r", "")
Selection.InsertBefore "- Section "
Selection.InsertAfter " " & Chr(34)
Selection.Collapse wdCollapseEnd
ActiveDocument.Fields.Add Selection.Range, wdFieldEmpty, ftext
Selection.Collapse wdCollapseEnd
Selection.InsertAfter Chr(34) & " on page "
Selection.Collapse wdCollapseEnd
ActiveDocument.Fields.Add Selection.Range, wdFieldEmpty, Replace(ftext,
"REF", "PAGEREF")


and if the cross reference displayed 1,1, you would get

- Section 1.1 "[Heading 2 text]" on page [page number]

See the following page of fellow MVP Graham Mayor's website if you do not
know what to do with the above code:

http://www.gmayor.com/installing_macro.htm

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top