Search & Delete Notes Pages

J

jstengren

I posted this as a vague question some time back, and was asked for
more detail... so, I'll try and clarify:

I write training documentation, and in this documentation we
occasionally insert an 'instructor notes page'... which is basically a
page (always even-numbered) containing notes for the teacher regarding
the content on the next page. A document may have any number of these
notes pages, and we currently are using an autotext entry to insert the
page based on a heading style that breaks the page (so, no formal
page-break is used when inserting). However, this approach could be
changed.

After creating a document with n numbers of notes pages, I need to be
able to run a script or macro to programmatically loop through and
delete all of these notes pages. One of my co-workers recommended
attaching a bookmark to the notes page autotext, and then creating code
to loop through and delete the bookmarks (we don't use bookmarks
currently), resulting in a notes page free document. However, I found
out that I'd need a new bookmark name for each notes page I insert!
This becomes a problem for deletion because, even if I manually
bookmark every notes page, I don't have any code/script/macro that
would delete ALL sections defined by bookmarks within a document.

If there was a way to just say, "Delete all sections that are
bookmarked within this document." we may have a solution. Otherwise,
let's not think about bookmarks. Is there a way I could use
find/replace on the style used for the heading text on the notes page?
Or, perhaps use a specific font for notes and find/delete that font
style? Or could I somehow customize the page/section breaks for notes
pages? The possibilities are wide-open.

I look forward to your feedback, and feel free to ask questions if
anything needs clarification.
 
J

jstengren

I had an idea... since each of these notes pages is started with a
*heading-notes style and ends with a page break, can't I somehow search
the document for the*heading-notes style, then define a section from
that style to the next page break, and then delete -- loop through the
entire document repeating that process?
 
R

Russ

Jstengren,
Reply in middle of text.
I had an idea... since each of these notes pages is started with a
*heading-notes style and ends with a page break, can't I somehow search
the document for the*heading-notes style, then define a section from
that style to the next page break, and then delete -- loop through the
entire document repeating that process?
Dim aBookMark As Word.Bookmark
For Each aBookMark In ActiveDocument.Bookmarks
aBookMark.Range.Expand Unit:=wdSection
aBookMark.Range.Delete
Next aBookMark
End Sub

This works, if your notes are delineated by section breaks before and after;
and each has a bookmark embedded within. Or leave out the expand line of
code, if each note is bookmarked as a whole and not 'sectioned' off.
Also, you could could format your notes' font as hidden and show or hide the
text or option to print hidden text or not.
 

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