Combine Word Basic macro with Delete Hidden Text macro

E

Ermine

This is actually a followup of previous "Problem with MS Word macro" question
that was answered successfully. I was wondering how I could combine the
Delete Hidden Text macro code that Anne Troy and Helmut Weber submitted with
the Word Basic macro that Deletes All Comments in the document, thus
attaining one button that "cleans up" the document of both hidden text and
comments. Thank You!
Ermine
 
H

Howard Kaikow

I've not seen the code of which you are speaking, but most any macros can be
combined into one and invoked with a single button.

If you have code that is invoked by a button, all you need to do is combine
the other code into that code.
 
E

Ermine

Listed below is the code I was referring to. I attempted to add
WordBasic.DeleteAllCommentsInDoc to it at the end before the End With
statement. When that didn't work, I tried before the End Sub statement. I
also tried adding it at the beginning. I get a VB error in all cases. I'm
sure the problem is the fact that I don't really know the code. I thought it
might work using the code that was generated when I recorded the steps
invoked by the command "Delete All Comments In Doc. Thanks for your help!
Ermine

Sub Macro1()
'
' Macro1 Macro
' Macro recorded 9/30/2004 by Anne Troy
'
Selection.Find.ClearFormatting
With Selection.Find.Font
.Hidden = True
End With
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "^?"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub
 
H

Helmut Weber

Hi Ermine,
how about this, anywhere in your code:
Dim oCmm As Comment
For Each oCmm In ActiveDocument.Comments
oCmm.Delete
Next
---
Greetings from Bavaria, Germany
Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word XP, Win 98
http://word.mvps.org/
 

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