Reading, not Running, a Macro from VBA code

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Yesterday, 19:15
Joined
Feb 28, 2001
Messages
30,472
Because of some unusual documentation requirements (U.S. Dept. of Navy), I have built a cross-referencer that works by opening the various collections of my database. It steps through the contents thereof, examining each in turn (in design mode). I make entries in a separate table, then run a report off the result. It sounds bizarre but it is incredibly useful if you have lots of forms, reports, tables, or queries to maintain - and I do. For instance, a simple query finds every place where I referenced item XYZ - and finding the reference is of course the first step in any maintenance operation.

My problem is that I cannot see the contents of a macro from my VBA code. There is a DoCmd.OpenForm, a .OpenReport, a .OpenQuery, etc., all of them allowing a "design mode" operation - but no .OpenMacro (at least not that I could find in Access 97).

I suppose I could manually export the macros as VBA code - but who wants to do ANYTHING manually? Besides, in line with the idea of automating things, I really don't want to have do to that many exports by hand every time I update any macro.

Does anyone have any ideas about how to open a macro (script) from VBA in a way that lets me see the contents without actually running the macro? I'll even consider "backdoor" methods if required.
 
Ok this doesn't answer your question fully but it may get you started in the right direction.

Open any macro and hit the print preview button. A nice report is made with all the macro properties, conditions, etc...

If the properties can be put on a report there must be a way to get them for your own custom use.

[This message has been edited by Talismanic (edited 07-13-2001).]
 
Talismanic, I know there are ways to get to the stuff I want, I agree it HAS to be there. For instance, you can also do a "Save As (VBA Code)" on a macro through what appears to be a save-wizard. But here is where I have run afoul of whatever is funky about macros:

If you do a

DoCmd.RunCommand acCmdViewMacros
DoCmd.SelectObject acMacro, {macroname}
DoCmd.RunCommand acCmdDesign

you get told that "Design View is not available from here." Even though at that point the Macro window is open and the desired macro has been selected.

If instead of the acCmdDesign you do

DoCmd.RunCommand acCmdConvertMacrosToVisualBasic

you get told that this option is not possible because you are already in Break Mode and can't run code in that context. Which means that something isn't re-entrant recursive somewhere.

I did get it to start the conversion but it put up the last phase of the dialogue sequence, which is a box with two things to be checked or unchecked regarding the properties of the operation. And it won't let me specify the options, so I turned off warnings and that's when it stopped me about the "can't run code in break mode."

To say that this is ugly doesn't come close to reality. So far, this problem has put the UG in ugly.

Anyone else who has any ideas, send 'em my way. (By the way, this doesn't seem to be any better in Acc2K.)
 

Users who are viewing this thread

Back
Top Bottom