|
-
Nov 11th, 2003, 12:57 AM
#1
Thread Starter
Member
Erase File Properties of MS Office Files
Hi,
I have been using the following Excel Macro which erases all the properties (Custom and embedded) from all MS Excel files placed in the folder c:\folder1\.
VB Code:
'--------Code Start--------------
Sub Properties()
MyPath = "C:\folder1"
MyFile = Dir(MyPath & Application.PathSeparator & _
"*.xls", vbDirectory)
Application.ScreenUpdating = False
Do While MyFile <> ""
If MyFile = ThisWorkbook.Name Then GoTo ResumeSub:
Workbooks.Open (MyPath & "\" & MyFile)
For I = ActiveWorkbook.CustomDocumentProperties.Count To 1 Step -1
ActiveWorkbook.CustomDocumentProperties.Item(I).Delete
Next
On Error Resume Next
For I = ActiveWorkbook.BuiltinDocumentProperties.Count To 1 Step -1
ActiveWorkbook.BuiltinDocumentProperties.Item(I) = ""
Next
Workbooks(MyFile).Close True
ResumeSub:
MyFile = Dir
Loop
Application.ScreenUpdating = True
End Sub
'--------Code End--------------
Similarly, I have been using the following VBA code for MS Word files as an embedded macro.
VB Code:
'---------Code Start----------
Sub Properties()
MyPath = "C:\folder1"
MyFile = Dir(MyPath & Application.PathSeparator & _
"*.doc", vbDirectory)
Application.ScreenUpdating = False
Do While MyFile <> ""
If MyFile = ThisDocument.Name Then GoTo ResumeSub:
Documents.Open (MyPath & "\" & MyFile)
For I = ActiveDocument.CustomDocumentProperties.Count To 1 Step -1
ActiveDocument.CustomDocumentProperties.Item(I).Delete
Next
On Error Resume Next
For I = ActiveDocument.BuiltInDocumentProperties.Count To 1 Step -1
ActiveDocument.BuiltInDocumentProperties.Item(I) = ""
Next
Documents(MyFile).Close True
ResumeSub:
MyFile = Dir
Loop
Application.ScreenUpdating = True
End Sub
'--------Code End--------------
Now I want to convert these 2 macros to a standalone single VB application which will erase all the file properties from all the Excel and Word files kept in c:\folder1\.
Going further, can somebody help me design a code which can do the same for MS PowerPoint files?
Please can someone help me in this.
Thanks in Advance,
Lonely
I Was Born Lonely, Lived Lonely .... And Will Die Lonely!!
-
Nov 16th, 2003, 06:28 PM
#2
Fanatic Member
Re: Erase File Properties of MS Office Files
You just need to do something like this:
VB Code:
Set appExcel = CreateOjbect("Excel.Application")
With app.Excel"
..your code
End With
Then in your code put dot "." before each Excel property or method. ".Workbooks"; ".WctiveWorkbook";, etc. so that they rfer back tothe appExcel. Hey Presto! VBA is now VB. Same deal with Word.
-
Nov 18th, 2003, 04:30 AM
#3
Thread Starter
Member
thanks
Thanks WorkHorse
I Was Born Lonely, Lived Lonely .... And Will Die Lonely!!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|