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 / August 2005

Tip: Looking for answers? Try searching our database.

Replacing Bookmark Text - Userforms

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Wendy D - 17 Aug 2005 15:20 GMT
(FYI - I posted this on the beginners, general, and userforms boards.)

I  have created a template where I created a userform with 2 "fields"
(ProjectName and TaskName).  Each field corresponds w/a bookmark.  I'm using
REF commands to link/repeat the bookmarks in the footer of the report.  It is
all working well except that the data that is input through the userform is
getting added to the (default) bookmark text instead of replacing it.  I
found a MVP document that gives me a general idea of what I need to do (set a
bookmark range variable) {MVP Doc:  Inserting text at a bookmark without
deleting the bookmark}.  It includes a subroutine when using a
macros/userform, but I'm not sure where to put it.  Can anyone help me with
this???

THANK YOU!
Wendy

Now, template bookmarks look like:  [ProjectName] and [TaskName].  If I
input a 1 (for project name) and a 2 (for task name) in the userform when I
open a new document, the bookmark data changes to:  [1ProjectName] and
[2TaskName].  I need it to change to [1] and [2] (but keep the bookmarks).

My VBA code has:

AUTONEW MODULE
Sub AutoNew()
'
' AutoNew Macro
' Macro created 8/16/2005 by wdaniels
'
UserForm1.Show

End Sub

USERFORM - Commandbutton1
Private Sub CommandButton1_Click()
With ActiveDocument
   .Bookmarks("ProjectName").Range _
   .InsertBefore TextBox1
   .Bookmarks("TaskName").Range _
   .InsertBefore TextBox2
End With
       
UserForm1.Hide

End Sub
Jean-Guy Marcil - 17 Aug 2005 16:00 GMT
Wendy D was telling us:
Wendy D nous racontait que :

> (FYI - I posted this on the beginners, general, and userforms boards.)

Thanks for letting us know that you have multiposted your message (Same
message in diffrent groups at the same time). You can crosspost if it is
absolutely necessary (in this case it isn't, the userform board would have
been enough). If you do, include all the group names in the To: field when
creating the message. For example:
   "To: microsoft.public.word.vba.beginners,
microsoft.public.word.vba.general, microsoft.public.word.vba.userforms"

This way all replies will appear at the same time in all groups and
everybody will see all the answers regardless of the group they are viewing
your post from. This will tell someone that it has already been answered
(They will see the answers in the thread), thus avoiding wasting their time
answering to a post that has already been replied to. Multiposting (has you
have doe) is not good NG etiquette, and it forces people to track down your
other messages to reply to them as well, whereas crosspoting is more
acceptable, although not usually necessary.

> I  have created a template where I created a userform with 2 "fields"
> (ProjectName and TaskName).  Each field corresponds w/a bookmark.
[quoted text clipped - 6 lines]
> bookmark}.  It includes a subroutine when using a macros/userform,
> but I'm not sure where to put it.  Can anyone help me with this???

Put the MVP code in the click event of the button that will carry out the
process from the userform.

> USERFORM - Commandbutton1
> Private Sub CommandButton1_Click()
[quoted text clipped - 8 lines]
>
> End Sub

Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org 

 
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.