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 / February 2007

Tip: Looking for answers? Try searching our database.

repeating data not updating all fields, only first

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Mary B. - 05 Feb 2007 06:51 GMT
I've created a 13 page form which reuses several pieces of data throughout.  
I've created a userform interface to the form template to gather the data and
disperse the data throughout the document after opening the template.  

I've created bookmarks to correspond to the data, using the [] method of
creating bookmarks.  In every subsequent reference to the bookmark (where I
want the bookmark to expand the data to what's entered on the userform) I've
used cross-references.

However, consistently only the first field referenced gets updated.  All of
the other fields remain as the cross reference { REF BName \h }, rather than
expanding to the name entered in the BName field on the userform.

I've used Greg Maxey's code in the userform
 With ActiveDocument
    .Bookmarks("Text1").Range.InsertBefore TextBox1
    .Bookmarks("Text2").Range.InsertBefore TextBox2
      ... etc.
 End With
 UserForm1.Hide

and used the autonew macro for the create button with UserForm1.Show to
execute upon the click of the create button.

I feel like I'm missing something huge here ... like asking it to update ALL
fields throughout the document.

This is my first template, my first userform, my first bookmark, and my
first crossreference use.  Any ideas?

--Mary
Greg Maxey - 05 Feb 2007 09:01 GMT
Mary,

> I've used Greg Maxey's code in the userform

Greg Maxey doesn't remember where or when he posted that code.  I don't
completely understand what you have done in your document, but the
statement:

.Bookmarks("Text1").Range.InsertBefore TextBox1

Doesnt' put in text "in" the bookmark.  Try:

Sub Test()
Dim oRng As Word.Range
With ActiveDocument
  Set oRng = .Bookmarks("Text1").Range
  oRng.Text = TextBox1
  .Bookmarks.Add "Text1", oRng
  Set oRng = .Bookmarks("Text2").Range
  oRng.Text = TextBox2
  .Bookmarks.Add "Text2", oRng
End With
 UserForm1.Hide
End Sub

Signature

Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.

> I've created a 13 page form which reuses several pieces of data
> throughout.
[quoted text clipped - 34 lines]
>
> --Mary
Peter Jamieson - 05 Feb 2007 14:17 GMT
\h hides the result so you may need to get trid of that too.

Peter Jamieson

> I've created a 13 page form which reuses several pieces of data
> throughout.
[quoted text clipped - 34 lines]
>
> --Mary
 
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.