Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Clear text after a bookmark

1,331 views
Skip to first unread message

Colin Telfer

unread,
Mar 24, 2007, 4:26:47 AM3/24/07
to
can anybody help me with some code for MS word 2003. I want to clear the
text / characters/ numbers after a bookmark leaving the bookmark intact.

.Bookmarks("Fax_no").Select
Selection.MoveRight Unit:=wdCharacter, Count:=15, Extend:=wdExtend
Selection.Delete Unit:=wdCharacter, Count:=1

this is the code i have sussed out so far, the only thing is it deletes the
line and the bookmark which i don't wish to do.

Can anybody help?

Also can anybody recommend a book for word VBA as i find the MS online help
manual useless?

Cheers
Colin


Doug Robbins - Word MVP

unread,
Mar 24, 2007, 5:00:36 AM3/24/07
to
See my response to your post in the customization newsgroup. Please do not
post the same question separately to multiple newsgroups.

--
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

"Colin Telfer" <colin....@ntlworld.com> wrote in message
news:bh5Nh.9071$Kk5....@newsfe1-win.ntli.net...

Helmut Weber

unread,
Mar 24, 2007, 5:06:12 AM3/24/07
to
Hi Colin,

so many ways,

delete 15 characters after a bookmark:

Sub Test400()
Dim lng As Long
Dim rng As Range
Set rng = ActiveDocument.Bookmarks("fax_no").Range
With rng
For lng = 1 To 15
.Characters.Last.Next = ""
Next
End With
End Sub


>Also can anybody recommend a book for word VBA
>as i find the MS online help manual useless?

Maybe, but not me.
The only thing I can say is that I prefer thick books.

Visit: http://word.mvps.org/index.html

HTH

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

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

alkremer

unread,
Nov 17, 2009, 5:42:40 PM11/17/09
to
What if I don't know how much data is following the bookmark? I'd like to be able to clear whatever went in there, so that the doc is ready for the next set of data.

Thanks!

Al

Helmut Weber wrote:

Re: Clear text after a bookmark
24-Mar-07

Hi Colin,

so many ways,

delete 15 characters after a bookmark:

Sub Test400()
Dim lng As Long
Dim rng As Range
Set rng = ActiveDocument.Bookmarks("fax_no").Range
With rng
For lng = 1 To 15
.Characters.Last.Next = ""
Next
End With
End Sub

Maybe, but not me.


The only thing I can say is that I prefer thick books.

Visit: http://word.mvps.org/index.html

HTH

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

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

Previous Posts In This Thread:

On Saturday, March 24, 2007 3:26 AM
Colin Telfer wrote:

Clear text after a bookmark


can anybody help me with some code for MS word 2003. I want to clear the
text / characters/ numbers after a bookmark leaving the bookmark intact.

.Bookmarks("Fax_no").Select
Selection.MoveRight Unit:=wdCharacter, Count:=15, Extend:=wdExtend
Selection.Delete Unit:=wdCharacter, Count:=1

this is the code i have sussed out so far, the only thing is it deletes the
line and the bookmark which i don't wish to do.

Can anybody help?

Also can anybody recommend a book for word VBA as i find the MS online help
manual useless?

Cheers
Colin

On Saturday, March 24, 2007 4:00 AM


Doug Robbins - Word MVP wrote:

See my response to your post in the customization newsgroup.
See my response to your post in the customization newsgroup. Please do not
post the same question separately to multiple newsgroups.

--
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

"Colin Telfer" <colin....@ntlworld.com> wrote in message
news:bh5Nh.9071$Kk5....@newsfe1-win.ntli.net...

On Saturday, March 24, 2007 4:06 AM
Helmut Weber wrote:

Re: Clear text after a bookmark
Hi Colin,

so many ways,

delete 15 characters after a bookmark:

Sub Test400()
Dim lng As Long
Dim rng As Range
Set rng = ActiveDocument.Bookmarks("fax_no").Range
With rng
For lng = 1 To 15
.Characters.Last.Next = ""
Next
End With
End Sub

Maybe, but not me.


The only thing I can say is that I prefer thick books.

Visit: http://word.mvps.org/index.html

HTH

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

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

EggHeadCafe - Software Developer Portal of Choice
ASP.NET Color Tool Derived from Reflection
http://www.eggheadcafe.com/tutorials/aspnet/a657aa86-1abe-4a5f-9c04-bb778fb8bfb7/aspnet-color-tool-derive.aspx

Doug Robbins - Word MVP

unread,
Nov 17, 2009, 7:00:57 PM11/17/09
to
See http://word.mvps.org/FAQs/MacrosVBA/WorkWithBookmarks.htm

--
Hope this helps,

Doug Robbins - Word MVP

Please reply only to the newsgroups unless you wish to obtain my services on
a paid professional basis.
"Al Kremer" wrote in message
news:2009111717...@westernphysicians.com...

Jay Freedman

unread,
Nov 17, 2009, 7:35:58 PM11/17/09
to

The best answer is to create the form as a *template* from which you
create new documents with the File > New command. Every new document
opens with the bookmarks already cleared (because that's how they're
stored in the template) and you don't have to worry about how much
gets inserted.

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.

BigAlK

unread,
Nov 18, 2009, 10:11:03 AM11/18/09
to
Forgive my inexperience...

Is there a way for me to programmatically "File > New" so as to create the
form repeatedly? I am reading a file and applying the data to the form, one
line at a time. I should be able to program so as to know where the bottom of
the page is, and thus submit each page to be printed.

It really would help if I could blank out existing data following a bookmark
because I will have to create multiple pages of detail info, with the main
data staying the same. To be able to keep that data intact, and just refill
the detail info would be great.

I appreciate your help, Jay. Anything else you can do to help me on this
would be greatly appreciated.

Al

"Jay Freedman" wrote:

> .
>

Doug Robbins - Word MVP

unread,
Nov 18, 2009, 2:17:19 PM11/18/09
to
See the article “Combining FormFields and Mail Merge” on the following page
of fellow MVP Graham Mayor’s website:

http://www.gmayor.com/Form_Fields_and_Mail_Merge.htm


--
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, originally posted via msnews.microsoft.com

"BigAlK" <Big...@discussions.microsoft.com> wrote in message
news:39505358-9538-4D97...@microsoft.com...

0 new messages