Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / November 2007

Tip: Looking for answers? Try searching our database.

Cross Reference Macro to Current Paragraph

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Kurtis - 23 Jul 2006 17:49 GMT
I am having a problem with a cross reference and would really appreciate some
help.  What I am trying to do is create a macro that will insert a full
context cross reference that references the current paragraph.  For instance,
par. 3.5 states "except as provided on Schedule 3.5.  Here is my code so far:

Selection.InsertCrossReference ReferenceType:="Numbered item", _
       ReferenceKind:=wdNumberFullContext, ReferenceItem:="?",
InsertAsHyperlink _
       :=True, IncludePosition:=False
End Sub

Any help on this would be greatly appreciated.
macropod - 24 Jul 2006 01:47 GMT
Hi Kurtis,

The ReferenceItem will be a bookmark - either one you've created or one that
Word has created and for which you know the ID/Name.

Cheers

Signature

macropod
[MVP - Microsoft Word]

> I am having a problem with a cross reference and would really appreciate some
> help.  What I am trying to do is create a macro that will insert a full
[quoted text clipped - 8 lines]
>
> Any help on this would be greatly appreciated.
Kurtis - 24 Jul 2006 13:32 GMT
Thanks for your response.  That makes sense, but how do I automate the
process?  How can I make it reflect the correct paragraph context each time
the macro is run?  

> Hi Kurtis,
>
[quoted text clipped - 18 lines]
> >
> > Any help on this would be greatly appreciated.
Kurtis - 24 Jul 2006 15:46 GMT
Here is the new code:

With ActiveDocument.Bookmarks
       .Add Range:=Selection.Range, Name:="b"
       .DefaultSorting = wdSortByLocation
       .ShowHidden = True
   End With
   Selection.InsertCrossReference ReferenceType:="Bookmark",
ReferenceKind:= _
       wdNumberFullContext, ReferenceItem:="b", InsertAsHyperlink:=True, _
       IncludePosition:=False
End Sub

Is there a way to generate a new bookmark Name (in this case "b") and copy
it to the ReferenceItem (b) each time the macro is run?

> Thanks for your response.  That makes sense, but how do I automate the
> process?  How can I make it reflect the correct paragraph context each time
[quoted text clipped - 22 lines]
> > >
> > > Any help on this would be greatly appreciated.
Russ - 30 Jul 2006 08:34 GMT
Kurtis,

You could try:
Dim n as Long
Dim myBookmark as String

n = ActiveDocument.Bookmarks.Count + 1
myBookmark = "b" & Cstr(n)

Then replace "b" in your code below with the variable myBookmark, verbatim
(without quotation marks), in both places.

> Here is the new code:
>
[quoted text clipped - 38 lines]
>>>>
>>>> Any help on this would be greatly appreciated.

Signature

Russ

drsmN0SPAMikleAThotmailD0Tcom.INVALID

Kurtis - 31 Jul 2006 14:15 GMT
Russ, that worked!  Thank you very much for helping me about.

> Kurtis,
>
[quoted text clipped - 50 lines]
> >>>>
> >>>> Any help on this would be greatly appreciated.
Mickey - 01 Nov 2007 22:53 GMT
I know I'm getting into this late but could this code be modified to create a
cross reference based on existing bookmarks in the document.  The situation
is this....I have multiple headers in a document due to portrait and
landscape pages.  There are 4 bookmarks in the header (DOC_NAME, DOC_VERSION,
DOC_TITLE, DOC_SITE).  The headers each need the same bookmarks.  I have a
macro to add the  bookmarks but the bookmarks are only retained in the last
header.  I'm wondering if I can search the headers where the bookmark was
lost and include cross reference code.  For example, search for "[DOC_NAME]
and have code that cross references it to the bookmark DOC_NAME.  

Any help is very much appreciated.

Thanks,
Mickey

> Kurtis,
>
[quoted text clipped - 50 lines]
> >>>>
> >>>> Any help on this would be greatly appreciated.
Russ - 04 Nov 2007 07:43 GMT
Mickey,
I think your question was answered by Tony in the other thread:
"Retaining Bookmarks in Autotext Macros"

> I know I'm getting into this late but could this code be modified to create a
> cross reference based on existing bookmarks in the document.  The situation
[quoted text clipped - 66 lines]
>>>>>>
>>>>>> Any help on this would be greatly appreciated.

Signature

Russ

drsmN0SPAMikleAThotmailD0Tcom.INVALID

Helmut Weber - 30 Jul 2006 08:47 GMT
Hi Kurtis

as far as I see, you are inserting a crossreference
to a bookmark in the bookmark [] or adjacent ][ to it.

Doesn't make sense to me.

Signature

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.