Author Topic: Is it possible to remove Visio file metadata with some VBA?  (Read 503 times)

0 Members and 1 Guest are viewing this topic.

Visisthebest

  • Hero Member
  • *****
  • Posts: 663
Is it possible to remove Visio file metadata with some VBA?
« on: November 07, 2022, 04:12:01 PM »
Does anyone know: is it possible to remove Visio file metadata with some VBA? (metadata of info like file author).
Visio 2021 Professional

Nikolay

  • Hero Member
  • *****
  • Posts: 1135
    • UnmanagedVisio

Visisthebest

  • Hero Member
  • *****
  • Posts: 663
Re: Is it possible to remove Visio file metadata with some VBA?
« Reply #2 on: November 08, 2022, 04:27:34 AM »
Thank you Nikolay very useful this is possible with VBA, I am thinking as a next step:

1. Remove hidden information
2. Save file
3. Check the relevant 'fields' to make sure this information is deleted (strings set to '')

Is step 3 also possible with VBA I am wondering.
Visio 2021 Professional

Nikolay

  • Hero Member
  • *****
  • Posts: 1135
    • UnmanagedVisio
Re: Is it possible to remove Visio file metadata with some VBA?
« Reply #3 on: November 08, 2022, 05:41:17 AM »
Probably there is no point to check using the same API you just used to clear it.
That is, how would you know that the API that "checks" is more reliable than the API that "clears"?  ;D

BTW, the "Author" field is returned by Document.Creator

If you want to be 200% sure, extract the content of the file as XML, remove the information you don't like and then pack back.
Visio is not required to do that, just a zip/unzip app.
« Last Edit: November 08, 2022, 05:46:41 AM by Nikolay »

Visisthebest

  • Hero Member
  • *****
  • Posts: 663
Re: Is it possible to remove Visio file metadata with some VBA?
« Reply #4 on: November 08, 2022, 05:54:17 AM »
Thank you Nikolay, related to this I understand LINQ is a very powerful way to query data from Visio files from its internal XML format.
Visio 2021 Professional

Nikolay

  • Hero Member
  • *****
  • Posts: 1135
    • UnmanagedVisio
Re: Is it possible to remove Visio file metadata with some VBA?
« Reply #5 on: November 08, 2022, 06:14:54 AM »
I'm not quite sure about LINQ (do you mean, the LINQ from .NET framework, or some app?).
To verify the author is not there, notepad should be enough actually :)

Visisthebest

  • Hero Member
  • *****
  • Posts: 663
Re: Is it possible to remove Visio file metadata with some VBA?
« Reply #6 on: November 08, 2022, 07:37:53 AM »
Yes of course, but for some more advanced use cases VB.NET/C# LINQ can be quite powerful with XML.
Visio 2021 Professional