Hi Stephen,
stay away from the selection.
Yes, easier said than done.
It's about five years I was told so.
Have a look at this one,
which you may adapt to your needs.
I couldn't find a way without deleting a bookmark
and restoring it. But this is common practise anyway,
when filling including bookmarks with text.
As it happens, the code works here and now
on any kind of bookmark.
I didn't care about the formatting.
I'm hoping, you didn't expect a ready to use solution
Sub InsertBeforeBookmark()
Dim rTmp1 As Range
Dim rtmp2 As Range
Dim lTmp As Long
Dim lTmpr As Long
sTmp = "xxxxxxxxxxxx" & vbCr
For lTmp = 1 To 3
With ActiveDocument.Bookmarks("Start")
lTmpr = Len(.Range)
Set rTmp1 = .Range
.Delete
End With
With rTmp1
.InsertBefore sTmp
.start = .start + Len(sTmp)
.Bookmarks.Add "Start"
End With
With ActiveDocument.Bookmarks("Start")
Set rTmp1 = .Range
.Delete
End With
Set rtmp2 = rTmp1
With rtmp2
.Collapse
.Tables.Add rtmp2, 4, 4
' beware of linebreaks by the newsreader, rewrite it this
.start =
ActiveDocument.Tables(ActiveDocument.Tables.Count).Range.Characters.Last.Next.start
.Select ' for testing remove later
.End = .start + lTmpr
Stop ' for testing remove later
.Select ' for testing remove later
Stop ' for testing remove later
.Bookmarks.Add "Start"
End With
Next
End Sub
HTH

Signature
Greetings from Bavaria, Germany
Helmut Weber, MVP WordVBA
Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
Fred - 20 Apr 2007 08:03 GMT
Helmut pardon my ignorance by I receive errors on this test at sTmp first
because it is not defined so I did and then because I did? I had one
bookmark in document" and was expecting it to put XXXXXX etc before the
bookmark(s) - did I miss the point?
Have a look at this one, which you may adapt to your needs. I couldn't find
a 'way without deleting a bookmark and restoring it. But this is common
practise 'anyway, when filling including bookmarks with text.
'As it happens, the code works here and now on any kind of bookmark.
'I didn't care about the formatting. I'm hoping, you didn't expect a ready
to use 'solution
Sub InsertBeforeBookmark()
Dim rTmp1 As Range
Dim rtmp2 As Range
Dim sTmp As Range
Dim lTmp As Long
Dim lTmpr As Long
sTmp = "XXXXXXXXXXXXX" & vbCr 'Runtime error 91 object
variable or block variable not set???
For lTmp = 1 To 3
With ActiveDocument.Bookmarks("Start")
lTmpr = Len(.Range)
Set rTmp1 = .Range
.Delete
End With
With rTmp1
.InsertBefore sTmp
.Start = .Start + Len(sTmp)
.Bookmarks.Add "Start"
End With
With ActiveDocument.Bookmarks("Start")
Set rTmp1 = .Range
.Delete
End With
Set rtmp2 = rTmp1
With rtmp2
.Collapse
.Tables.Add rtmp2, 4, 4
' beware of linebreaks by the newsreader, rewrite it this
.Start =
ActiveDocument.Tables(ActiveDocument.Tables.Count).Range.Characters.Last.Next.Start
.Select ' for testing remove later
.End = .Start + lTmpr
Stop ' for testing remove later
.Select ' for testing remove later
Stop ' for testing remove later
.Bookmarks.Add "Start"
End With
Next
End Sub
> Hi Stephen,
>
[quoted text clipped - 57 lines]
>
> HTH
Helmut Weber - 20 Apr 2007 08:15 GMT
Hi Stephen,
add
Dim sTmp as String
Things like that happen,
if one comments out
' option explicit
for whatever reason,
and forgets to enable it again.
--
Greetings from Bavaria, Germany
Helmut Weber, MVP WordVBA
"red.sys" & chr(64) & "t-online.de"
Word 2002, Windows 2000 (german versions)
Stephen English - 23 Apr 2007 14:00 GMT
Hi Helmut
THank you for taking the time to give me such a detailed response.
I am writing a database for Rotary when I have time to produce a District
Directory.
Regards
Stephen

Signature
Regards
Stephen English
> Hi Stephen,
>
[quoted text clipped - 13 lines]
> "red.sys" & chr(64) & "t-online.de"
> Word 2002, Windows 2000 (german versions)