Reading macro code?

  • Thread starter Thread starter Andreas
  • Start date Start date
A

Andreas

Is there any possibllity to read a Macro into VB (or VBA)?
It seems, as if Microsoft hides the statements of
Access-Macros.

As far as I see, there is only a very booring solution:
Convert it to VBA. Then you can use the Application Object
to read the (into VBA translated Macro) lines.

Is there any other solution arround?
Thank you
Andreas
 
Allen, thank you very much.
It is not the best solution, but nevertheless it is one.
Andreas
 
Hi,

It is a bit complicated, but there's a way to do it. I am preparing an
example database that shows how to read, create and modiffy macros using VBA
(by the moment, only for A2k or +)

If you are really interested in it, probably you will find it in about 15
days from now in my web site, in section "Descargas" (I have to say that
everything is writen in spanish...).

--
Saludos desde Barcelona
Juan M. Afan de Ribera
<MVP Ms Access>
http://www.juanmafan.tk
http://www.clikear.com/webs4/juanmafan
 
can you tell me: which object has the method SaveAsText.
with doCmd it does not work.
Andreas

It is a method of the Application object, but you need only type the line as
shown in Allen's example (with your own parameters to replace those shown in the
quotes, of course). It is undocumented, so you won't find it in the help file.
 
Bruce,
thanks! But that sounds strange:
I work in VB (outside of a database)
and a stub with
dim obj as access
set obj=getobject("MyDB.mdb")
obj.SaveAsText ...
does not work.
Andreas
 
Bruce,
thanks! But that sounds strange:
I work in VB (outside of a database)
and a stub with
dim obj as access
set obj=getobject("MyDB.mdb")
obj.SaveAsText ...
does not work.

Try:

'****
Dim obj As Object
Dim strDbName As String
strDbName = "C:\MyPath\MyDB.mdb"
Set obj = GetObject(strDbName, "Access.Application")

'export table to text
obj.SaveAsText ...

'And don't forget to "Set obj = Nothing" when done.
'****
 
Bingo!
It works!
Thank you.
(Why is there no direct object to read the macrocode?)
Andreas
 
Bingo!
It works!
Thank you.
(Why is there no direct object to read the macrocode?)

I suppose that there is little call for it. I, for one, have never felt the need
to see a macro through any interface other than the macro editor.

:-)
 
I suppose that there is little call for it. I, for one, have never felt the need
to see a macro through any interface other than the macro
editor.
Yes, me too, until I started to develop a MDB-Explorer,
which list all objects (and its dependencies).
Andreas
 
Back
Top