can I name a section break in a word document?

J

Jay Freedman

Elaine said:
Is it possible to name a section break in a word document?

No, but you can enclose it in a bookmark and refer to it by the bookmark's
name. What are you trying to do with it?

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 
E

Elaine

Hi Jay,

I have a 'contract' that I need to attach exhibits too, sometimes when the
contract comes back the customer decides to remove or add exhibits. I want
to find an easy way to delete the exhibit.

Currently I have a template that will insert the exhibits by putting in a
section break and importing in the file. I want to create a button that will
prompt my end user for the exhibit name and delete all pages that are part of
that exhibit....

Any help would be greatly appreciated.
 
R

Russ

Elaine,
I hope some of this code puts you on the right path.
After importing the file in your code, include some or all of this code to
set up the bookmark.

Bookmark names can't have any punctuation (nor spaces) except the underscore
character!!!


Dim myExhibitName As String
myExhibitName = "My Exhibit of July 7 2007"
'Can't use a comma in potential bookmark name above.


'Make bookmark name legitimate by trimming end spaces and replacing
'other spaces with underscore characters and length < 46 characters.
myExhibitName = Left(Trim _
(Replace(myExhibitName, " ", "_")), 45)


'Paraphrased from VBA Help: Predefined bookmarks, \Section is current
'section, including the break at the end of the section, if any.
'This line assigns the current section a useful bookmark name by the .Copy
'method.
ActiveDocument.Bookmarks("\Section").Copy myExhibitName

P.S.
If I were doing this, I would probably create a userform dialog for adding
and deleting names. A dropdown list of bookmarks could be loaded with all
the current bookmark names for deletion and of course refreshed after a
deletion.
A textbox for input and an 'execute' button would name the collections and
add them to a section along with a legitimate bookmark name and of course
refresh the dropdown list of bookmarks.
 

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