Get VISIO XML to string in VBA

Posted on 2005-03-30
Medium Priority
Last Modified: 2008-01-09
Hi everyone,

I have a question that is critical and is driving me crazy. Visio 2003 allows you to save documents as XML. If you want to save it to a file, it is very easy and the API allows that. However, what I want to do is get the XML representation of the document in a string variable inside my VBA code.

So, basically I have a VB macro inside the Visio document and I have a string variable and I want to have the current XML representation of the Visio document.

How can I do this? i cannot have a file being saved in the hard drive. I must have the XML string from within the application!

Please help!


Question by:xargon_123
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
LVL 12

Expert Comment

ID: 13669963
I don't know much abour Visio but have you tried

myXMLStr = ActiveDocument.SolutionXMLElement(ActiveDocument.SolutionXMLElementName)

Author Comment

ID: 13678821
Well, the SolutionXML element is only one tag in the overall XML that encapsulates custom XML in the Visio document. I need to get the whole document XML.
LVL 12

Expert Comment

ID: 13679226
Office 365 Training for Admins - 7 Day Trial

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.


Author Comment

ID: 13679251

Again, the problem is that the SolutionXML does not get the whole Visio document. Only a sub-set of it.

That guy in the link has the same problem as me!
LVL 12

Accepted Solution

gbzhhu earned 1000 total points
ID: 13679276
For what I can see so far there is no simple property in the Visio object modal that extracts the documents whole xml, something like Document.GetXML  I will carry on digging around.

Author Comment

ID: 13679477
Yeah, I know. That is why I am going crazy :(

I am also hoping that there is a work-around by creating a file in memory and saving the data there. But again, I do not know how to create a file completeiy in memory  and be able to use it in the SaveAs method as the SaveAs methods expects the file path string.


Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question