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 2006

Tip: Looking for answers? Try searching our database.

The bookmark is crashed by the text

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Gérard Ducouret - 26 Feb 2006 18:40 GMT
Hello,
How can I write some text at a Word bookmark, via VBA, without losing the
bookmark, whether or not the bookmark currently encloses any text?
Thanks for your help,

Gérard
Helmut Weber - 26 Feb 2006 19:29 GMT
Hi Gérard,

for encluding bookmarks, like [some text]:

Public Sub NewText(sBkm As String, sTmp As String)
Dim rTmp As Range
With ActiveDocument.Bookmarks
  If .Exists(sBkm) Then
     Set rTmp = .Item(sBkm).Range
     rTmp.Text = sTmp
     .Add Name:=sBkm, Range:=rTmp
  End If
End With
End Sub

Sub test4001()
  NewText "Mark01", "2nd Text"
End Sub

The bookmark gets lost and has to be recreated.

With excluding bookmarks, like ][,
it's not a problem anyway.

There is a nice tool from Greg Maxey:
http://gregmaxey.mvps.org/Bookmark_Tool.htm

Signature

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

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

Doug Robbins - Word MVP - 26 Feb 2006 22:11 GMT
See the article "Inserting text at a bookmark without deleting the bookmark"
at:

http://www.word.mvps.org/FAQs/MacrosVBA/InsertingTextAtBookmark.htm

Signature

Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

> Hello,
> How can I write some text at a Word bookmark, via VBA, without losing the
> bookmark, whether or not the bookmark currently encloses any text?
> Thanks for your help,
>
> Gérard

Rate this thread:






 
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.