Results 1 to 8 of 8
  1. #1
    Join Date
    Oct 2003
    Location
    CT
    Posts
    8

    Unanswered: Macros with, ugh, hard-coded information

    I have several Access 97 databases that have hard-coded filename paths embedded in both macros as well as modules.

    Updating the modules is easy (there is only one of them). Updating the macros will be a trick as there are over 180 macros (and not all of them have embedded filesname paths).

    Is there an easy way to either

    a) quickly locate those macros that have an embedded filename (according to the documentation left by the previous developer, the macros that conatin filenames all have the RunApp command in them)
    -or-
    b) globally update the macros, replacing the filename path with another

    I realize that option (b) is not ideal, but we are in the process of replacing these Access databases with other applications.

    Thanks
    Tim Smith

  2. #2
    Join Date
    Dec 2003
    Location
    Toronto, Ont. Canada
    Posts
    238

    Re: Macros with, ugh, hard-coded information

    Ewwww... 180 macros...

    Well Tim... I've looked and looked, but I can't seem to find any magic code that'll update the commands in the macros... I could be wrong but I think you may be outta luck on this one...

    My only idea to cut down on the time of updating them is to convert the macros to VB and then do a quick Find and Replace...

    I'll be watching to see if anyone else knows of a programmatic solution...

  3. #3
    Join Date
    Oct 2003
    Location
    CT
    Posts
    8

    Re: Macros with, ugh, hard-coded information

    with respect to the Macro->VB solution, once converted, is there a way to convert them back? That is one thing I thought about doing but was unsure if I caould go back to macros once the search/replace was done.

    Thanks

  4. #4
    Join Date
    Jun 2002
    Location
    Mpls/St.Paul area
    Posts
    303
    For what its worth, you can convert all the macros to code. Then you have more global search and replace capabilities. You can also add comments, make constants (directories) and even generalize the code. For example if you have a macro on every form that closes the form, just have one public function that closes it.

    Regardless it sounds like a lot of work.
    John
    This is the day the Lord has made, I will rejoice and be glad in it.

  5. #5
    Join Date
    Jun 2002
    Location
    Mpls/St.Paul area
    Posts
    303
    Oops - sorry. I type slowly. Looks like Trudi is helping you out. Regarding going back to macros, would that be like going back to horse and buggy? There are lots of advantages to using code.

    Have fun
    John
    This is the day the Lord has made, I will rejoice and be glad in it.

  6. #6
    Join Date
    Dec 2003
    Location
    Dallas, TX
    Posts
    1,004

    Cool Re: Macros with, ugh, hard-coded information

    Trudi,

    If I'm not mistaken when you convert macros to code, the macros are still there until you delete them. At least mine stayed there and once I learned to coding behind them I at that time went manually to delete each macro as I needed to. But as was said, once converted to code, why go back? Just for old times sake??

    Have a nice one
    Bud

  7. #7
    Join Date
    Dec 2003
    Location
    Toronto, Ont. Canada
    Posts
    238

    Re: Macros with, ugh, hard-coded information

    Originally posted by Bud
    Trudi,

    If I'm not mistaken when you convert macros to code, the macros are still there until you delete them. At least mine stayed there and once I learned to coding behind them I at that time went manually to delete each macro as I needed to. But as was said, once converted to code, why go back? Just for old times sake??

    Have a nice one
    Bud
    I completely agree with you Bud... I'd just convert them, update the code with Find/Replace, save the changes, and delete the old macros... (saving back up copies of the database both before and after the conversion of course! lol )

  8. #8
    Join Date
    Sep 2003
    Location
    T.O.
    Posts
    326
    Trudi's right, I tried searching many forums when I had to do this, and there is simply no way to do the update you want.

    The closest I've come was dumping the contents of the macro to a text file:

    SaveAsText acMacro, "Macro1", "C:\mac.txt"

    But this produces a report rather than a recordset so it's hard to tie the filename to the macro name.
    All code ADO/ADOX unless otherwise specified.
    Mike.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •