View Full Version : Creating a macro that makes a cross-reference
NewED
08-22-2010, 12:43 PM
Hello,
I've got Office 2003.
I would like to create a macro that will allow an automatic creation of a cross-reference to a specific paragraph chosen by the user.
The desired macro should do the following basic actions:
Go to Reference - Cross-reference - Select "Select a ruling (full context)"
At this point, I'd like the macro to enable the user to select the wanted paragraph from the original list MsWord opens.
I've tried to record a macro and study the right code lines, but it didn't quite work.
Could this macro be arranged?
thanks,
ED
fumei
08-22-2010, 08:07 PM
"I've tried to record a macro and study the right code lines, but it didn't quite work."
It didn't quite work - this is not very informative. Not work? Nothing happened. Something happened, but it was not what you expected? Something happened, but it was wrong? Something happened but it was not enough for what you wanted?
In order to really help, post your original code and we'll see about adjusting things.
I suspect though, that you will need to select a paragraph first, rather than start the cross-reference process and THEN select a paragraph. If this is a crucial issue for you, state so.
NewED
08-23-2010, 10:21 PM
Thank you for your response.
I'll try to further explain my question:
A
Let's assume that my document looks like this:
1. every man eats
2. Fat men eat more
3. everybody loves apples
4. Fat men eat more from the fruit mentioned in section 2
I want to enable the user to stand after the word "mentioned in" in section 4 and press a macro that will automatically cross-reference to a different wanted section in the document (section 3 in my example)
B
I do agree that the paragraph/desired location should be selected first by the user.
However, when using a cross-reference, first you suppose to choose the paragraph/location you want to add a cross reference to[ and only then choose the paragraph you want to reference to .
C
What I want to do is as follows:
1. the user chooses the location where he wants to add the cross-reference to, by standing with the mouse on the desires location.
2. The user activates the macro
3. The macro opens the oridinary list of paragraphs/sections that word offers.
4. At this time the macro's action can end, the user chooses the desired section from the list and everybody is happy.
D
I tried to record the following set of actions:
Go to Reference - Cross-reference - Select "Select a ruling (full context)"
and the following lines of code have been created.
As you can see this code doesn't give me a proper solution since it doesn't enable the user to choose a wanted paragraph/section from a list of paragraphs/sections in the document.
Selection.InsertCrossReference ReferenceType:="numbered item", ReferenceKind _ :=wdNumberFullContext, ReferenceItem:="3", InsertAsHyperlink:=True, _
IncludePosition:=False, SeparateNumbers:=False, SeparatorString:=" "
E
I trully hope that this explanation is understood this time, and
I would appreciate an answer
fumei
08-25-2010, 06:14 PM
I am having hard time with: "list of paragraphs/sections in the document"
Paragraphs "slash" sections?? Paragraphs and sections are very very different things. I am not seeing this. What list?
NewED
08-26-2010, 11:24 AM
I'm talking about the list that MSword opens everytime you choose the following orders from the menu:
Reference --> Cross-reference --> "Select a ruling (full context)"
At this point there is a list of paragraphs you can choose from...
(I have 0ffice 2003)
The paragraphs I refer to are the paragraphs shown in this dropdown list.
NewED
08-30-2010, 03:40 AM
Is it so complex?
fumei
08-30-2010, 11:10 AM
Sorry. I can not help. I do not have 2003 and I do not see "Select a ruling (full context)"
geekgirlau
08-31-2010, 08:07 PM
Hi NewED,
Would it not be simpler to just have a shortcut to display the standard Word Cross Reference dialog? I don't see that what you're proposing would be an improvement (or quicker to activate) than the built-in feature.
NewED
09-01-2010, 01:11 PM
I don't think I quite understand.
How can I make a proper shortcut that would immediatly open the desired cross eference dialog ? The problem is that the users are not very familiar with
the cross reference dialog and I want to make their life easier.
geekgirlau
09-01-2010, 03:43 PM
Dialogs(wdDialogInsertCrossReference).Show
NewED
09-02-2010, 12:43 PM
that's a very simple yet wonderful idea.
Is there a way to predefine the type of the cross-reference (instead of choosing it from the dialog)?
Thanks
NewED
09-05-2010, 11:14 AM
please, I need your help...
Tinbendr
09-05-2010, 12:33 PM
I'd have to agree with GeekGirl, in that I don't think you'll save a lot of time doing this.
A training document might be more appropriate in this instance.
But, if you like, post a sample document so I can follow your description.
NewED
09-08-2010, 03:05 AM
Thanks for your reply.
However I think a sample document won't help this time.
I'll try to explain:
Earlier I gave the following example:
Let's assume that my document looks like this:
1. every man eats
2. Fat men eat more
3. everybody loves apples
4. Fat men eat more from the fruit mentioned in section 2
I want to enable the user to stand after the word "mentioned in" in caluse no. 4 and press a button that will automatically cross-reference to a different clause in the document (clause no. 2 in my example)
Geekgirlau had a nice idea: she suggested I use the following shortcut instead:
Dialogs(wdDialogInsertCrossReference).Show
This code opens the correct dialog, but I also want to predefine the type of the cross-reference (instead of choosing it from the dialog everytime).
Now I'm asking if that's possible.
I hope It's clear now...
Tinbendr
09-08-2010, 05:32 AM
It appears that the parameters for Cross reference dialogs are undocumented, but here's one link (http://groups.google.com/group/microsoft.public.word.vba.general/browse_thread/thread/91146553ba43049b/0f8bed01e009d5f0?hl=en&lnk=gst&q=wdDialogInsertCrossReference#0f8bed01e009d5f0) that talks about it.
Sorry I can't be of more help.
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.