|
#1
|
|||
|
|||
How to Dump all Macro to the log
Hi,
Is there a quick way to dump all macros (temp, project, and environment) to the log? Thanks, SMckeown |
#2
|
|||
|
|||
Here's how I did it, dump them to a file and then read the file into the log, but I figure there's probably a better way.
http://www.kinook.com/Forum/showthread.php?t=4468 Using a VBScript "Run Script" action: Dim objMacro, theNumberOfThem, theFileName1, theFileName2 Set objMacro = Application.Macros(vbldTemporary) 'just the temporary macros theNumberOfThem = objMacro.Count theFileName1 = "C:\Tempmacros" objMacro.Save(theFileName1) Builder.LogMessage theNumberOfThem & " Temporary macros have been dumped to a file called: " & theFileName1 ' collection of all unique macros, with highest precedence for macros with same name in multiple collections Set objMacro = Application.Macros(vbldMacroAll) theNumberOfThem = objMacro.Count theFileName2 = "C:\AllActiveMacros" objMacro.Save(theFileName2) Builder.LogMessage "All (" & theNumberOfThem & " total) Active macros have been dumped to a file called: " & theFileName2 Last edited by joe12; 05-26-2011 at 11:15 PM. |
#3
|
|||
|
|||
See the attached sample.
|
#4
|
|||
|
|||
I used the Run Script step from the above "LogMacros.bld" example.
It worked for a while, but now out of the blue, I get an error on that VBScript code. The error reads: Error in Run Script (VBScript) script code at Line 15, Column 4 (Type mismatch: 'Application.ExpandMacrosAndScript') 6/6/2011 5:37:12 PM: Step '14 - Dump All Macro Information to Log' failed 6/6/2011 5:37:12 PM: Build ended (elapsed = 00:00:00). In the log , it stopped right after writing the lines: ============================================= ****** temporary macros ****** So I examined my Temporary macros, and sure enough I found what is causing the failure. I have an ADO_RS macro sitting around in the temp macros (from an earlier call to SQL with a Loop Action Step to parse that SQL just after). If I delete that ADO_RS macro, then the "Dump All Macros" step goes back to working. Is there a way to make this VBScript more robust so that it will dump all the macros even when the macros collections contain one or more macros that are some type of list or whatever? |
#5
|
|||
|
|||
Here is an updated project which handles that.
|
Thread Tools | |
Display Modes | Rate This Thread |
|
|