I see no reliable way to document the source of a model that's been reverse engineered.
At minimum the server instance and database used in the merge operation need to be stored in the model but I can neither retrieve them directly from the MergeModelObject nor specify them explicitly TO the MergeModelObject. This leaves me with no reliable way to insure data in the model matches the values used in the merge operation without reading the .cmo file which I'm loathe to do using string operations.
As a workaround, I would suggest storing them in an Attachment to the Physical model.
Yes of course, that's one of the few places available for ad hoc values. In this case Comments might actually be better given they automatically track the history and include the timestamp and user associated with an update.The problem is, that advice doesn't help GET the values I'd like to store. Thus the title "How can a macro retrieve..."
I'm not totally clear on what you're trying to do, but a macro can access attachment information. So if the server instance and database are stored in an attachment, a macro can access that information.
And how do the values get there? A macro puts them there? Where does the macro get that information from in order to put it there???
Presently there is (best I can tell) no reliable source other than the .cmo file used to create the model. That file is in XML format. Thus I need to read the values from these XPath locations in that file:
String based extraction of XML is tedious and fragile at best.
It would have to be put there manually - this is just a one time thing that would have to be part of your initial model creation process. After that, a macro would be able to read that information out of the attachment.
I'm not sure why you think string based extraction is fragile. I use this technique quite often in my macros. I have one macro that uses a text file to store the UI settings for the user, similar to a .cmo file. I have another macro that reads the DDL text file generated by ER Studio and fixes various issues. And I have macros that read .cmo files as well. I don't have any problem with any of these macros or the technique.
1) To what end might a macro want to read such information out of the attachment? To automate updating the model? The MergeModelObject doesn't take any part of a connection string as an argument. What part of ensuring the model was updated from the correct source is automated by entering it manually unless the data entered is USED by the update process?
2) If it's so simple to read reliably, why wouldn't you just post the code and propose it as an answer instead of spending a paragraph telling me it's simple to do reliably with no indication of how. I clearly think that without some library the code will be complex, precarious or both.
The Microsoft DOM offers an easy way to do this. It works for VBA. Not sure if everyone tried to use it under ER Studio macros.
Looks perfect if it's accessible but after following it's parents to the top of the doc it only talks about system.xml, it doesn't really give any hints as to how to get access. Do you happen to know what it's called in the [references] dialog or what name to use in a NEW ... statement so as to create an instance of it?
That does work. Naturally it's not terribly intuitive how to make it work though because this particular XML contains DTD and apparently DTDs pose a security risk and the docs don't make it obvious how to get around the roadblocks.
Nevertheless after adding the reference named "MicrosoftXML, v6.0 (6.0)" this code worked.
Dim XmlDoc As MSXML2.DOMDocument60
Dim Server As String
Dim DbName As String
Set XmlDoc = New MSXML2.DOMDocument60
If Not XmlDoc.load(CompareParamFullname) Then MsgBox XmlDoc.parseError.reason ReturnEnd IfServer = XmlDoc.selectSingleNode("/ERStudioCompareMergeWizard/CStringVariables/@m_DbServerString").Text DbName = XmlDoc.selectSingleNode("/ERStudioCompareMergeWizard/CStringVariables/@m_csDatabase").Text
Above, CompareParamFullname is the fully qualified filename of the .cmo file I will be passing to the compare and merge utility. This ensures my model comments can contain the actual values used when the model gets updated.