Jump to content
Kevin Smith

How to remove metadata from Word document (using OLE)

Recommended Posts

Hello,

I'm trying to remove Word metadata using OLE. I can remove Author but I can't remove "Last author". I use following code:

  vEditor:= CreateOleObject('Word.Application');
  vEditor.Visible:=True;
  vDoc:= vEditor.Documents.Open('sample.docx');
  vDoc.BuiltInDocumentProperties.Item['Author']):= '';//It works!
  vDoc.BuiltInDocumentProperties.Item['Last Author']):= '';//It doesn't work
  vDoc.Save;
  vDoc.Close;
  vEditor.Quit;

I hope you have some experience with such a task and you can help me.

If there is other solution than using OLE please also give me an info.

 

Share this post


Link to post
5 minutes ago, Kevin Smith said:

Hello,

I'm trying to remove Word metadata using OLE. I can remove Author but I can't remove "Last author". I use following code:


  vEditor:= CreateOleObject('Word.Application');
  vEditor.Visible:=True;
  vDoc:= vEditor.Documents.Open('sample.docx');
  vDoc.BuiltInDocumentProperties.Item['Author']):= '';//It works!
  vDoc.BuiltInDocumentProperties.Item['Last Author']):= '';//It doesn't work
  vDoc.Save;
  vDoc.Close;
  vEditor.Quit;

I hope you have some experience with such a task and you can help me.

If there is other solution than using OLE please also give me an info.

 

Isn't the Last Author set when the file is saved? That would simply undo your change...

Share this post


Link to post
Quote

Isn't the Last Author set when the file is saved? That would simply undo your change...

Yes it looks like. Do you know how I can get rid of "Last author" property ?

Edited by Kevin Smith

Share this post


Link to post

I believe you would have to do that in Word:

 

(WINDOWS) Microsoft Word 2010, 2013, 2016:
  1. Go to “File”
  2. Select “Info”
  3. Click on “Check for issues”
  4. Click on “Inspect document”
  5. In the “Document Inspector” dialog box, select the check boxes to choose the types of hidden content that you want to be inspected.
  6. Click “Remove All”
  7. Click “Close”
  8. Save the document.

 

Share this post


Link to post

Process the XML directly. Should actually be a really easy job for a SAX based processor. Even better, you don't need any COM automation of Word. If you need to do this in your product then I guess Delphi is best. If it's a helper script for personal use I'd do it in Python or similar.

Edited by David Heffernan

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×