Visio Guy

Visio Discussions => Programming & Code => Topic started by: Visisthebest on November 07, 2022, 09:12:01 PM

Title: Is it possible to remove Visio file metadata with some VBA?
Post by: Visisthebest on November 07, 2022, 09:12:01 PM
Does anyone know: is it possible to remove Visio file metadata with some VBA? (metadata of info like file author).
Title: Re: Is it possible to remove Visio file metadata with some VBA?
Post by: Nikolay on November 07, 2022, 10:01:43 PM
Yes, "Remove Hidden Information":

https://learn.microsoft.com/en-us/office/vba/api/visio.document.removehiddeninformation
Title: Re: Is it possible to remove Visio file metadata with some VBA?
Post by: Visisthebest on November 08, 2022, 09: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.
Title: Re: Is it possible to remove Visio file metadata with some VBA?
Post by: Nikolay on November 08, 2022, 10: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.
Title: Re: Is it possible to remove Visio file metadata with some VBA?
Post by: Visisthebest on November 08, 2022, 10: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.
Title: Re: Is it possible to remove Visio file metadata with some VBA?
Post by: Nikolay on November 08, 2022, 11: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 :)
Title: Re: Is it possible to remove Visio file metadata with some VBA?
Post by: Visisthebest on November 08, 2022, 12:37:53 PM
Yes of course, but for some more advanced use cases VB.NET/C# LINQ can be quite powerful with XML.