David Cuthill was telling us:
David Cuthill nous racontait que :
> I am using the following code to locate and place a bookmark - the
> problem is after the code executes I also end up with a bookmark with
[quoted text clipped - 15 lines]
> ...
> Next i
These hidden (hidden because they start with an underscore) bookmarks are
usually added when cross references, links or TOC are added to the document.
Sometimes when you copy/paste between applications, the source or the
destination is marked with a bookmark. I haven't had the inclination to
study this, so I do not know why, but it has never caused me, or anybody I
have heard of, any problems.
I used your code on my Word 2003, and I did not see those hidden bookmarks.
As a suggestion, try to use With ... End With Statements in your code. It
executes faster and makes it lighter to read. For example, your code could
be written as:
'Do not forget to Dim and type your variables...
Dim oWordDoc As Document
Dim TabCnt As Long
Dim Rng As Range
Set oWordDoc = ActiveDocument
With oWordDoc
TabCnt = .Tables.Count
For i = 1 To TabCnt Step 4
z = CStr(i)
Set Rng = .Tables(i).Range
With Rng
'Why Copy? You are not pasting it anywhere, are you?
'Maybe the answer to your question is in the code you
'obviously snipped out... Are you pasting?
'If not, what are you doing?
'If so, see my comments above
' .Copy
.Collapse wdCollapseEnd
' .InsertAfter "" & vbCrLf
'Why the "" ? It does not do anything..., I replaced this by this line:
.InsertParagraphAfter
.Collapse wdCollapseEnd
End With
.Bookmarks.Add Name:="BarChart" & z, Range:=Rng
Next i
End With

Signature
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org
dcuthill - 25 Nov 2004 16:43 GMT
After sending this post I made one change that seemed to resolve the issue I
was having.
dim BMName as string
BMName = "BarChart" & z
ActiveDocument.Bookmarks.Add Name:=BMName, Range:=Rng
Thank you for the other suggestions. I think the copy command was left over
from something else I had been working on awhile ago.
> David Cuthill was telling us:
> David Cuthill nous racontait que :
[quoted text clipped - 60 lines]
> Next i
> End With