Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.newusers
[email protected] bmurphy@xlrotor.com is offline
external usenet poster
 
Posts: 21
Default need field to remove the first word in a cross reference

I have a cross-reference field in my document to a bookmark that
contains several words. Is there any way to remove the first word and
display the rest?

Thanks

Brian Murphy

  #2   Report Post  
Posted to microsoft.public.word.newusers
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default need field to remove the first word in a cross reference

Not without creating another bookmark

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org


wrote:
I have a cross-reference field in my document to a bookmark that
contains several words. Is there any way to remove the first word and
display the rest?

Thanks

Brian Murphy



  #3   Report Post  
Posted to microsoft.public.word.newusers
Stefan Blom Stefan Blom is offline
external usenet poster
 
Posts: 8,428
Default need field to remove the first word in a cross reference

Alternatively, you can redefine an existing bookmark, by selecting the
"other" words and then clicking the Add button (in the Bookmark dialog box).

Note that if this is a bookmark generated by Word, you will have to display
hidden bookmarks and click the "Location" radio button. Then Word highlights
the name of the current bookmark. Click Add to redefine the bookmark.

--
Stefan Blom
Microsoft Word MVP


"Graham Mayor" wrote in message
...
Not without creating another bookmark

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org


wrote:
I have a cross-reference field in my document to a bookmark that
contains several words. Is there any way to remove the first word and
display the rest?

Thanks

Brian Murphy








  #4   Report Post  
Posted to microsoft.public.word.newusers
[email protected] bmurphy@xlrotor.com is offline
external usenet poster
 
Posts: 21
Default need field to remove the first word in a cross reference

I was beginning to think it would come to this.

Since I'm using my own macros to put in captions and their cross
references, I should be able to work in the bookmark that I need.

When I insert a caption, I'll enclose the part I want to use later in
a regular bookmark. I'm pretty sure that when later selecting that
caption in the Insert/Cross Reference dialog Word will create it's
hidden bookmark (if it's not there already) with mine inside, and
create a cross reference to it's hidden bookmark. Then I'll have my
macro edit the cross reference field to change the bookmark label.

Does that sound like the way to go? If you have any suggestions on
this, please post back. Right now I don't how to find the tag for
what will be my bookmark.

Cordially,

Brian



On Sep 13, 1:25 am, "Graham Mayor" wrote:
Not without creating another bookmark

--

Graham Mayor - Word MVP

My web sitewww.gmayor.com
Word MVP web sitehttp://word.mvps.org


wrote:
I have a cross-reference field in my document to a bookmark that
contains several words. Is there any way to remove the first word and
display the rest?


Thanks


Brian Murphy



  #5   Report Post  
Posted to microsoft.public.word.newusers
[email protected] bmurphy@xlrotor.com is offline
external usenet poster
 
Posts: 21
Default need field to remove the first word in a cross reference

Thanks for the suggestion.

In my limited testing, Word doesn't give up that easy. I found that
if I redefine Word's hidden bookmark for the caption, Word creates a
new bookmark the next time I use the Cross Reference dialog to create
a reference to that caption.

Word won't use the modified bookmark, so I have to leave Word's
bookmark intact, and change the cross reference field created by Word
to point to my bookmark instead.

I just need to know how to find the tag for my bookmark that is
"inside" Word's bookmark.

Unless there is a built-in function that will do this (.Intersect ?),
I can loop through all the bookmarks in the document and check
their .Range.Start & .End properties to find the right one.

In concept this ought to work, but this is turning out to be a lot
harder than it ought to be.

Brian



On Sep 13, 9:05 am, "Stefan Blom" wrote:
Alternatively, you can redefine an existing bookmark, by selecting the
"other" words and then clicking the Add button (in the Bookmark dialog box).

Note that if this is a bookmark generated by Word, you will have to display
hidden bookmarks and click the "Location" radio button. Then Word highlights
the name of the current bookmark. Click Add to redefine the bookmark.

--
Stefan Blom
Microsoft Word MVP

"Graham Mayor" wrote in message

...

Not without creating another bookmark


--

Graham Mayor - Word MVP


My web sitewww.gmayor.com
Word MVP web sitehttp://word.mvps.org


wrote:
I have a cross-reference field in my document to a bookmark that
contains several words. Is there any way to remove the first word and
display the rest?


Thanks


Brian Murphy





  #6   Report Post  
Posted to microsoft.public.word.newusers
[email protected] bmurphy@xlrotor.com is offline
external usenet poster
 
Posts: 21
Default need field to remove the first word in a cross reference

I see there is a .InRange method. That might make this easier.

Brian

  #7   Report Post  
Posted to microsoft.public.word.newusers
Stefan Blom Stefan Blom is offline
external usenet poster
 
Posts: 8,428
Default need field to remove the first word in a cross reference

You are right: my suggestion can only be used to modify an existing
bookmark; it won't change how Word creates bookmarks. For that you will have
to use a macro (which, it seems, you are already doing anyway).

--
Stefan Blom
Microsoft Word MVP


wrote in message
ps.com...
Thanks for the suggestion.

In my limited testing, Word doesn't give up that easy. I found that
if I redefine Word's hidden bookmark for the caption, Word creates a
new bookmark the next time I use the Cross Reference dialog to create
a reference to that caption.

Word won't use the modified bookmark, so I have to leave Word's
bookmark intact, and change the cross reference field created by Word
to point to my bookmark instead.

I just need to know how to find the tag for my bookmark that is
"inside" Word's bookmark.

Unless there is a built-in function that will do this (.Intersect ?),
I can loop through all the bookmarks in the document and check
their .Range.Start & .End properties to find the right one.

In concept this ought to work, but this is turning out to be a lot
harder than it ought to be.

Brian



On Sep 13, 9:05 am, "Stefan Blom" wrote:
Alternatively, you can redefine an existing bookmark, by selecting the
"other" words and then clicking the Add button (in the Bookmark dialog
box).

Note that if this is a bookmark generated by Word, you will have to
display
hidden bookmarks and click the "Location" radio button. Then Word
highlights
the name of the current bookmark. Click Add to redefine the bookmark.

--
Stefan Blom
Microsoft Word MVP

"Graham Mayor" wrote in message

...

Not without creating another bookmark


--

Graham Mayor - Word MVP


My web sitewww.gmayor.com
Word MVP web sitehttp://word.mvps.org


wrote:
I have a cross-reference field in my document to a bookmark that
contains several words. Is there any way to remove the first word and
display the rest?


Thanks


Brian Murphy








  #8   Report Post  
Posted to microsoft.public.word.newusers
Bear[_2_] Bear[_2_] is offline
external usenet poster
 
Posts: 314
Default need field to remove the first word in a cross reference

Brian:

You should just replace Word's Cross-Reference command with your own. (Just
kidding. I did, but it's not trivial. But oh, so satisfying.)

Anyway... Can't you get the range of the bookmark and find the first or
second bookmark with it (that's your bookmark). Maybe easier if you use a
fixed prefix for your bookmarks. The following is pseudo-code to illustrate
the idea.

Dim objRange as Range
Dim strBookmark as String
Dim objBookmark as Bookmark

' Insert code to determine the name of Word's bookmark
' and save it in strBookmark

set objRange = Activedocument.Bookmarks(strBookmark)
For each objBookmark in objRange.Bookmarks
If Left(objBookmark.Name, 3) = "BXM" Then
' Your processing here
End If
Next objBookmark

~~~~~

This doesn't have any error handling or anything, but I hope you get the idea.

Bear

--
Windows XP, Word 2000



  #9   Report Post  
Posted to microsoft.public.word.newusers
[email protected] bmurphy@xlrotor.com is offline
external usenet poster
 
Posts: 21
Default need field to remove the first word in a cross reference

Here's the code I'm presently using. It's a bit spartan, but it gets
the job done. Two macros. One called from a macro that had just
inserted a caption, and the other called from a macro that had just
inserted a cross reference.

I've been working a lot with VBA in excel since 1995, but Word VBA is
entirely new to me. If you see anything I ought to be doing
differently, please let me know.

Cheers,

Brian

Sub mrfAddBookmark()
'right after creating a caption that has a label followed by a caption
number
'define a bookmark that contains just the caption number
'the bookmark ID will be mrf########## where the digits are from the
current time of day
'it doesn't matter if the caption number includes a chapter number
(maybe), and any separator is okay
'upon entering this routine the caption number should be selected
ActiveDocument.Bookmarks.Add Range:=Selection.Range, Name:="mrf" &
Int((Now - Int(Now)) * 10 ^ 9)
Selection.MoveRight Unit:=wdCharacter, Count:=2
End Sub

Sub mrfChangeCrossReference()
'this operates on a REF cross-reference field for a caption
'The bookmark ID in the field is one of Word's hidden bookmarks that
includes the caption label
'There should be one of my own bookmarks inside that one that excludes
the label
'This routine changes the bookmark ID in the cross-reference from
Word's to mine
Dim s$, s1$, s2$, s3$, rng As Range
Selection.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend
Set rng = Selection.Fields(1).Code
s = Trim(rng.Text)
s1 = Mid(s, 1, InStr(s, " "))
s = Mid(s, Len(s1) + 1)
s2 = Mid(s, 1, InStr(s, " ") - 1)
s = Mid(s, Len(s2) + 1)
s2 = ActiveDocument.Bookmarks(s2).Range.Bookmarks(1).Na me
s = " " & s1 & s2 & s3 & " "
rng.Text = s
Selection.Fields(1).Update
Selection.MoveRight Unit:=wdCharacter, Count:=1
End Sub




On Sep 14, 10:36 am, Bear (nospam) wrote:
Brian:

You should just replace Word's Cross-Reference command with your own. (Just
kidding. I did, but it's not trivial. But oh, so satisfying.)

Anyway... Can't you get the range of the bookmark and find the first or
second bookmark with it (that's your bookmark). Maybe easier if you use a
fixed prefix for your bookmarks. The following is pseudo-code to illustrate
the idea.

Dim objRange as Range
Dim strBookmark as String
Dim objBookmark as Bookmark

' Insert code to determine the name of Word's bookmark
' and save it in strBookmark

set objRange = Activedocument.Bookmarks(strBookmark)
For each objBookmark in objRange.Bookmarks
If Left(objBookmark.Name, 3) = "BXM" Then
' Your processing here
End If
Next objBookmark

~~~~~

This doesn't have any error handling or anything, but I hope you get the idea.

Bear


  #10   Report Post  
Posted to microsoft.public.word.newusers
Bear[_2_] Bear[_2_] is offline
external usenet poster
 
Posts: 314
Default need field to remove the first word in a cross reference

Brian:

I'm sorry, but my brain just refuses to analyze code on a Monday morning, so
I'm not going to be of any use.

However, you're working in difficult, dangerous territory when you use the
selection and the Word GUI interface the way you're doing to determine stuff.

Maybe you could use the field code and result properties with more confidence.

Use selection.paragraphs(1) to set a range, then examine range.fields to
find the REF field.

Parse out the REF field code to get the hidden bookmark name.

Use activedocument.bookmarks(name) to set another range (that's your caption
with the nested bookmarks, one of which is yours).

Examine the bookmarks in that range to find the one starting with "mrf" to
get that bookmark's name.

Set the code for the original REF field to use the mrf bookmark name rather
than the original hidden bookmark name.

That's the strategy I'd use, anyway.

Bear
--
Windows XP, Word 2000


Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Keep cross-reference but remove hyperlink swimmer Microsoft Word Help 6 January 30th 07 10:09 AM
Form field cross reference not working in protected form Christine Microsoft Word Help 4 December 4th 06 12:08 PM
cross reference field with space and colored text Hilary Microsoft Word Help 2 November 2nd 05 09:42 PM
(cross-reference usage)I see "Error! Reference source not found". spiderou Microsoft Word Help 2 July 8th 05 09:34 PM
SEQ Field not in cross-reference reference type pull-down menu The Josh Microsoft Word Help 5 May 25th 05 02:27 PM


All times are GMT +1. The time now is 12:39 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"