PDA

View Full Version : Word "Save Clean" Sub



bstephens
09-14-2010, 12:22 AM
So, I am trying to write a good "save clean" sub for word 2007/2010, which will get rid of metadata, personal information, etc, etc..

This was my starting point:

'Save File as a Clean Document
Sub FileSaveAsCleanDeprecated()

Dim arev As Revision
Dim StoryRange As Range
Dim oRange As Range

With ActiveDocument
For Each oRange In .StoryRanges
oRange.Revisions.AcceptAll
Next
End With

For Each cmt In ActiveDocument.Comments
cmt.Delete
Next

For Each StoryRange In ActiveDocument.StoryRanges
StoryRange.HighlightColorIndex = wdNoHighlight
Next StoryRange

Application.Dialogs(wdDialogFileSaveAs).Show
End Sub
which evolved into this:

Sub FileSaveAsClean()

ActiveDocument.RemoveDocumentInformation wdRDIAll

For Each StoryRange In ActiveDocument.StoryRanges
StoryRange.HighlightColorIndex = wdNoHighlight
Next StoryRange

Application.Dialogs(wdDialogFileSaveAs).Show

End Sub
I am also looking for a way to remove a style set used in our documents called "Custom Style Set", and have the text keep its formatting but have the standard word style set loaded.

Does anyone have any thoughts on how I can make a "save clean" function that will allow me to send word documents to outside parties without worrying about sending information which should otherwise be private? (ex: metadata including, document properties, authors information, editing time, track changes, comments, hidden text, highlights, document variables, "versions" information, fast saves, template information, should I be worried about anything else?)

Anyone already come up with some good code for a "save clean" function for what seems like a common problem?

Best,
Brian