Hi all,
I am using below macro to remove Document Properties, Personal Information & Custom XML Data. but what i am facing is when i run this macro all the .docx files will be as same extension. But when .doc and .docx will be mixed in the folder then it automatically changes .doc file extension to .rtf and .docx remains the same. Please help me to maintain same extension and let me know if other than removing property what all it does...Thanks in Advance.
I am using below macro to remove Document Properties, Personal Information & Custom XML Data. but what i am facing is when i run this macro all the .docx files will be as same extension. But when .doc and .docx will be mixed in the folder then it automatically changes .doc file extension to .rtf and .docx remains the same. Please help me to maintain same extension and let me know if other than removing property what all it does...Thanks in Advance.
Code:
Sub Inspection()
Application.ScreenUpdating = False
Dim strInFold As String, strOutFold As String, strFile As String, strOutFile As String, DocSrc As Document
'Call the GetFolder Function to determine the folder to process
strInFold = GetFolder
If strInFold = "" Then Exit Sub
strFile = Dir(strInFold & "*.docx", vbNormal)
'Check for documents in the folder - exit if none found
If strFile <> "" Then strOutFold = strInFold & "Inspected"
'Test for an existing outpfolder & create one if it doesn't already exist
If Dir(strOutFold, vbDirectory) = "" Then MkDir strOutFold
strFile = Dir(strInFold & "*.docx", vbNormal)
'Process all documents in the chosen folder
While strFile <> ""
Set DocSrc = Documents.Open(FileName:=strInFold & "" & strFile, AddTorecentFiles:=False, Visible:=False)
With DocSrc
'remove personal information
.RemoveDocumentInformation (wdRDIDocumentProperties)
.RemoveDocumentInformation (wdRDIDocumentServerProperties)
.RemoveDocumentInformation (wdRDIContentType)
'String variable for the output filenames
strOutFile = strOutFold & Split(.Name, ".")(0)
'Save and close the document
.SaveAs FileName:=strOutFile
.Close
End With
strFile = Dir()
Wend
Set Rng = Nothing: Set DocSrc = Nothing
Application.ScreenUpdating = True
End Sub
Function GetFolder(Optional Title As String, Optional RootFolder As Variant) As String
On Error Resume Next
GetFolder = CreateObject("Shell.Application").BrowseForFolder(0, Title, 0, RootFolder).Items.Item.Path
End Function
Last edited by a moderator: