Results 1 to 3 of 3

Thread: Erase File Properties of MS Office Files

  1. #1

    Thread Starter
    Member
    Join Date
    May 2003
    Posts
    52

    Question 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:
    1. '--------Code Start--------------
    2. Sub Properties()
    3. MyPath = "C:\folder1"
    4. MyFile = Dir(MyPath & Application.PathSeparator & _
    5. "*.xls", vbDirectory)
    6. Application.ScreenUpdating = False
    7. Do While MyFile <> ""
    8. If MyFile = ThisWorkbook.Name Then GoTo ResumeSub:
    9.     Workbooks.Open (MyPath & "\" & MyFile)
    10. For I = ActiveWorkbook.CustomDocumentProperties.Count To 1 Step -1
    11.     ActiveWorkbook.CustomDocumentProperties.Item(I).Delete
    12. Next
    13. On Error Resume Next
    14. For I = ActiveWorkbook.BuiltinDocumentProperties.Count To 1 Step -1
    15.     ActiveWorkbook.BuiltinDocumentProperties.Item(I) = ""
    16. Next
    17. Workbooks(MyFile).Close True
    18. ResumeSub:
    19.     MyFile = Dir
    20. Loop
    21.     Application.ScreenUpdating = True
    22. End Sub
    23. '--------Code End--------------

    Similarly, I have been using the following VBA code for MS Word files as an embedded macro.

    VB Code:
    1. '---------Code Start----------
    2. Sub Properties()
    3. MyPath = "C:\folder1"
    4. MyFile = Dir(MyPath & Application.PathSeparator & _
    5. "*.doc", vbDirectory)
    6. Application.ScreenUpdating = False
    7. Do While MyFile <> ""
    8. If MyFile = ThisDocument.Name Then GoTo ResumeSub:
    9. Documents.Open (MyPath & "\" & MyFile)
    10. For I = ActiveDocument.CustomDocumentProperties.Count To 1 Step -1
    11. ActiveDocument.CustomDocumentProperties.Item(I).Delete
    12. Next
    13. On Error Resume Next
    14. For I = ActiveDocument.BuiltInDocumentProperties.Count To 1 Step -1
    15. ActiveDocument.BuiltInDocumentProperties.Item(I) = ""
    16. Next
    17. Documents(MyFile).Close True
    18. ResumeSub:
    19. MyFile = Dir
    20. Loop
    21. Application.ScreenUpdating = True
    22. End Sub
    23. '--------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!!

  2. #2
    Fanatic Member WorkHorse's Avatar
    Join Date
    Jul 2002
    Location
    Where you live.
    Posts
    591

    Re: Erase File Properties of MS Office Files

    You just need to do something like this:

    VB Code:
    1. Set appExcel = CreateOjbect("Excel.Application")
    2. With app.Excel"
    3. ..your code
    4. 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.

  3. #3

    Thread Starter
    Member
    Join Date
    May 2003
    Posts
    52

    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
  •  



Click Here to Expand Forum to Full Width