mvpreq was telling us:
mvpreq nous racontait que :
> I need step wise help for creating a button for inserting bookmark,
> also second step is can a code be added to make the bookmark in
[quoted text clipped - 3 lines]
> another bookmark on clicking the button it inserts automatically
> "Bookmark2" and so on to "Bookmark3...."
Try this:
'_______________________________________
Sub InsertMyBookmark()
Const strBookRoot As String = "Bookmark"
Const strBookVar As String = "BookVar"
Dim lngBookNo As Long
'To keep track of the number to use
'Use document variables
'Custom properties could be used as well
With ActiveDocument.Variables
If .Count = 0 Then
lngBookNo = 1
Else
lngBookNo = CLng(.Item(strBookVar).Value) + 1
End If
.Item(strBookVar).Value = lngBookNo
End With
ActiveDocument.Bookmarks.Add strBookRoot & CStr(lngBookNo), _
Selection.Range
End Sub
'_______________________________________
Two comments:
If the user deletes text that contains bookmarks, you will not end up with a
perfectly numbered scheme. You could have Bookmark1, then Bookmark4,
Bookmark5 and Bookmark9.
Also, there is no guarantee that the location in the document will match the
numbering. You could have Bookmark4 before Bookmark1 to Bookmark3.

Signature
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org
mvpreq - 28 Nov 2006 06:30 GMT
Thanks Jean-Guy for your prompt response:
I will be able to work on this, on coming weekend and let you know how it
goes. Does this macro includes the sequence for creating a button or it is
only for the numbering scheme.
Deepak
mvpreq - 28 Nov 2006 07:02 GMT
Dear Jean-Guy:
I tried it briefly, it does insert bookmarks in the numbered manner but the
only problem I encountered is that when I tried experimenting by deleting
some bookmark it causes the "Word" to close with an error reporting screen.
Also please guide me how to make a button on the tool bar for this Macro
without each time going to Tool-Macros-Choosing Macro and choosing run.
Thanks for your time
Deepak
Jean-Guy Marcil - 28 Nov 2006 17:00 GMT
mvpreq was telling us:
mvpreq nous racontait que :
> Dear Jean-Guy:
>
> I tried it briefly, it does insert bookmarks in the numbered manner
> but the only problem I encountered is that when I tried experimenting
> by deleting some bookmark it causes the "Word" to close with an error
I doubt this has anything to do with the macro I posted.
Can post the exact steps you took that made your Word crash?
What Word version?
> reporting screen. Also please guide me how to make a button on the
> tool bar for this Macro without each time going to
> Tool-Macros-Choosing Macro and choosing run.
Use the information at
http://word.mvps.org/FAQs/Customization/AsgnCmdOrMacroToToolbar.htm
to either create a toolbar or simply add a button to an existing toolbar.
You also have to think about the storage... do you want this button
available to all Word documents or only those created from a particular
template?
If it is the latter, then add the code and the button to that template.

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