Hi,

I'd like use vba to modify an existing document
so that only those pages that contain markups
are saved (i.e. remove all pages that don't contain
markup)

Any help would be much appreciated.

I'm using the word 2003 object model

Thanks

finding markups in a word document by DA

DA
Thu Jul 01 01:12:44 CDT 2004

Hi Gary

Problem with working with pages is that they are never
static or classed as objects. Your best bet is probably
to section your document into pages, even if you have to
write another macro to do that. This way you can at least
target the sections (pages) that have markup and delete
them.

For example:

Dim mySection As Section
For Each mySection In ActiveDocument.Sections
If mySection.Range.Revisions.Count > 0 Then
mySection.Range.Delete
End If
Next mySection

Hope that helps,
Dennis

>-----Original Message-----
>Hi,
>
>I'd like use vba to modify an existing document
>so that only those pages that contain markups
>are saved (i.e. remove all pages that don't contain
>markup)
>
>Any help would be much appreciated.
>
>I'm using the word 2003 object model
>
>Thanks
>.
>

Re: finding markups in a word document by Jean-Guy

Jean-Guy
Thu Jul 01 08:51:52 CDT 2004

Bonjour,

Dans son message, < gary > écrivait :
In this message, < gary > wrote:

|| Hi,
||
|| I'd like use vba to modify an existing document
|| so that only those pages that contain markups
|| are saved (i.e. remove all pages that don't contain
|| markup)
||
|| Any help would be much appreciated.
||
|| I'm using the word 2003 object model
||

If by markup you mean revisions, try this code.
Note that at the beginning of the code I have to turn off track changes
otherwise the act of deleting a page will add a revision mark...

'_______________________________________
Dim PageRge As Range

Application.ScreenUpdating = False
ActiveDocument.TrackRevisions = False

With Selection
.HomeKey wdStory

Do While .Start < ActiveDocument.Range.End - 1
Set PageRge = .Bookmarks("\Page").Range
With PageRge
If .Revisions.Count > 0 Then
.Select
Selection.Collapse wdCollapseEnd
Else
.Delete
End If
End With
Loop

End With

Application.ScreenRefresh
Application.ScreenUpdating = True
'_______________________________________

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




Re: finding markups in a word document by gary

gary
Thu Jul 01 09:10:39 CDT 2004

> Hope that helps
>
> Dennis

Thanks for the quick reply, just what I was looking for

> Dim mySection As Section
> For Each mySection In ActiveDocument.Sections
> If mySection.Range.Revisions.Count > 0 Then
> mySection.Range.Delete
> End If
> Next mySection

pretty much used this code as is. Only tweak
was interating through sections from document end to
to beginning to save processor time (as a lot of sections
end up being deleted).

> Problem with working with pages is that they are never
> static or classed as objects. Your best bet is probably
> to section your document into pages, even if you have to
> write another macro to do that. This way you can at least
> target the sections (pages) that have markup and delete
> them.

Good advice - I mapped sections=pages

-Gary

Re: finding markups in a word document by gary

gary
Thu Jul 01 09:10:49 CDT 2004

> Hope that helps
>
> Dennis

Thanks for the quick reply, just what I was looking for

> Dim mySection As Section
> For Each mySection In ActiveDocument.Sections
> If mySection.Range.Revisions.Count > 0 Then
> mySection.Range.Delete
> End If
> Next mySection

pretty much used this code as is. Only tweak
was interating through sections from document end to
to beginning to save processor time (as a lot of sections
end up being deleted).

> Problem with working with pages is that they are never
> static or classed as objects. Your best bet is probably
> to section your document into pages, even if you have to
> write another macro to do that. This way you can at least
> target the sections (pages) that have markup and delete
> them.

Good advice - I mapped sections=pages

-Gary