defining range objects

L

Lenny

I want to add a button to an existing toolbar that when clicked, adds a
pre-defined table of contents. I am unfamiliar with using the range property
or object.

Most of the vb help on range object covers words, paragraphs, bookmarks and
cells. I have no way of knowing 'exactly' where the user will want or need
to insert the table of contents. It will most likely be at the top of page
created by an overset or a page break. Is there a way to set the range
reference to the position of the cursor within the document?

Regards - Lenny
 
P

Peter Jamieson

To set a range to the current location of the /insertion point/ or
selection, use e.g.

Dim rngSel As Word.Range
Set rngSel = Selection.Range

(However it is up to you to ensure that the Selection is in a place
where a ToC can successfully be inserted)

Peter Jamieson

http://tips.pjmsn.me.uk
Visit Londinium at http://www.ralphwatson.tv
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top