Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / April 2006

Tip: Looking for answers? Try searching our database.

What macro term will accept all format changes only?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
neutronjay - 29 Apr 2006 16:07 GMT
Within Track Changes I am able to manually select and accept a single format
change, but I want to be able to write a macro that will accept all format
changes at once (while leaving all text additions and deletions as is).  Does
anyone know the secret phrase I'm looking for?
Greg Maxey - 29 Apr 2006 16:24 GMT
Might be just as easy to do it like this:

Sub Scratchmaoro()
Dim oChg As Revision
For Each oChg In ActiveDocument.Revisions
 If oChg.Type = wdRevisionDelete Or oChg.Type = wdRevisionInsert Then
   'Do nothing
 Else
   oChg.Accept
 End If
Next oChg
End Sub

Signature

Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.

> Within Track Changes I am able to manually select and accept a single
> format change, but I want to be able to write a macro that will
> accept all format changes at once (while leaving all text additions
> and deletions as is).  Does anyone know the secret phrase I'm looking
> for?
Charles Kenyon - 29 Apr 2006 16:31 GMT
Nice!

> Might be just as easy to do it like this:
>
[quoted text clipped - 14 lines]
>> and deletions as is).  Does anyone know the secret phrase I'm looking
>> for?
neutronjay - 29 Apr 2006 16:58 GMT
Excellent!  Thank you very much!
-------------------------

> Might be just as easy to do it like this:
>
[quoted text clipped - 14 lines]
> > and deletions as is).  Does anyone know the secret phrase I'm looking
> > for?
Jay Freedman - 29 Apr 2006 16:40 GMT
Here's your macro:

Sub AcceptAllFormatChanges()
   Dim rev As Revision
   For Each rev In ActiveDocument.Revisions
       With rev
           If .Type = wdRevisionProperty Then .Accept
       End With
   Next rev
End Sub

--
Regards,
Jay Freedman
Microsoft Word MVP        FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.

>Within Track Changes I am able to manually select and accept a single format
>change, but I want to be able to write a macro that will accept all format
>changes at once (while leaving all text additions and deletions as is).  Does
>anyone know the secret phrase I'm looking for?
Charles Kenyon - 29 Apr 2006 17:02 GMT
As is often the case with help, it helps to know what you are looking for.
Looking under "revision constant" or "revision" or "constant" didn't help.
From vba Help after looking for wdRevisionDelete:
This example rejects the previous tracked change found if the change type is
deleted or inserted text. If the tracked change is a style change, the
change is accepted.

Set myRev = Selection.PreviousRevision(Wrap:=True)
If Not (myRev Is Nothing) Then
   Select Case myRev.Type
       Case wdRevisionDelete
           myRev.Reject
       Case wdRevisionInsert
           myRev.Reject
       Case wdRevisionStyle
           myRev.Accept
   End Select
End If
> Here's your macro:
>
[quoted text clipped - 20 lines]
>>Does
>>anyone know the secret phrase I'm looking for?
Greg Maxey - 29 Apr 2006 17:08 GMT
Jay,

I thought about that one, but I didn't have a good test document and so just
suggested to the route to explicitly ignore insertions and deletions.

Why the With/End With?
Signature

Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.

> Here's your macro:
>
[quoted text clipped - 12 lines]
>> additions and deletions as is).  Does anyone know the secret phrase
>> I'm looking for?
Jay Freedman - 30 Apr 2006 04:22 GMT
One reason is that any time I refer to two or more properties/methods
of the same object, I use a With statement. It reduces the time the
interpreter needs to dereference the object, and it also shortens the
code so it's more readable.

Another reason is that I have a code template (courtesy of an add-in
called MZ-Tools) that drops in everything except the innermost
statement with one click. :-)

--
Regards,
Jay Freedman
Microsoft Word MVP        FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.

>Jay,
>
[quoted text clipped - 18 lines]
>>> additions and deletions as is).  Does anyone know the secret phrase
>>> I'm looking for?
Greg Maxey - 30 Apr 2006 04:47 GMT
Oh, I see now.  The .Accept is the second property/method.

Signature

Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.

> One reason is that any time I refer to two or more properties/methods
> of the same object, I use a With statement. It reduces the time the
[quoted text clipped - 34 lines]
>>>> additions and deletions as is).  Does anyone know the secret phrase
>>>> I'm looking for?

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.