Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

VBA / XML elements / attributes?

Status
Not open for further replies.

justhumm

Structural
May 2, 2003
111
0
0
US
Just a random question that somebody else might know the answer to...

I have an Excel VBA macro that accesses some information from a custom ribbon (CUSTOMUI.XML).

The XML file is static and is not being modified by the macro. In the static XML file, I have the "tag" attribute including a portion of the "label" attribute for each element. This is a snippet from the current/working XML file:

XML:
<menu id="sMenu25" label="Pressure">
<button id="unit2501" [b][u]label="PSI"[/u][/b] tag="&quot;[b]PSI[/b]&quot;" onAction="Macro22" />
<button id="unit2502" [b][u]label="KSI"[/u][/b] tag="&quot;[b]KSI[/b]&quot;" onAction="Macro22" />
</menu >

I haven't been able to figure this out, but before I spend too much time driving down a dead end...With future editing/modifying of the XML file in mind, in EXCEL/VBA, is it possible to refer to another attribute, within an element?

XML:
<menu id="sMenu25" label="Pressure">
<button id="unit2501" label="PSI" tag="&quot;"&[b][u]label[/u][/b]&"&quot;" onAction="Macro22" />
<button id="unit2502" label="KSI" tag="&quot;"&[b][u]label[/u][/b]&"&quot;" onAction="Macro22" />
</menu >

Thanks!
 
Replies continue below

Recommended for you

I'm not sure exactly one way or the other, but if you are using the Microsoft customui editor there is a button to test whether the XML code is valid. So perhaps just try it and see, finding the exact format can be quite hard as documentation on custom ui ribbon elements can be quite brief on the net.

Your modification seems to only save the one location being hardcoded with the label name in the code though, which doesn't achieve much, if you want to remove the hardcoded label you can use the getLabel action with appropriate code within your VBA to allow you to change the labels within your VBA code (for example once XML is written it can be controlled dynamically by your VBA code which is easier to manage if you ever need to change the label text).
 
Status
Not open for further replies.
Back
Top