PDA

View Full Version : Macro no eval properly in script


pcts
05-20-2004, 04:16 PM
Suppose I have the following macros and their respective values:

MACRO1 = "58" (temporary macro)
MACRO2 = "Hello There %MACRO1%" (project macro)

When I hover the mouse over MACRO2 on the Macros tab, I correctly see a tooltip with the value "Hello There 58".

However, if I I try to access MACRO2 in a script step, I get the value "Hello There %MACRO1%", even though MACRO1 does have a value.

For example:
Set macrosProject = Application.Macros(vbldMacroProject)
Set macro2 = macrosProject.Item("MACRO2")
builder.LogMessage "Value is " & macro2.value

And I get
Value is Hello There %MACRO1%

Any idea what's going on?

kinook
05-20-2004, 04:50 PM
By design, the macro object's Value property returns the raw (unexpanded) value of the macro. To retrieve the expanded value, use:

Application.ExpandMacros("%MACRO2%")
-or-
Application.ExpandMacros(macro.Value)

or if the macro value might also contain script expression(s), use ExpandMacrosAndScript instead of ExpandMacros.