Results 1 to 10 of 10
  1. #1
    Join Date
    Jul 2010
    Location
    Springfield, IL
    Posts
    25

    How do you print a macro?

    I have a form that has a command button which executes a rather lengthy
    macro. Does anyone know how to write a report so I can keep a printed copy of


    the macro? I DO NOT want to use the built-in Database
    Documentor; the report isn't formatted the way I want? I would be happy to
    modify the Database Documentor report if I can find a way. I'm using Access 2010.

    Thanks!

    Chuck

  2. #2
    help_me_with_access is offline help_me_with_excel
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    262
    you can't. unless you have reverse engineering skills.

    software is the way it is, unless it's the newest age possible. access can't change. what format do you want? the documenter is actually pretty good, IMO. what's wrong with the format?

    essentially though, macros are nothing more than internal functions or methods being executed in order. that's exactly the reason why they all can be converted to visual basic code.

  3. #3
    Join Date
    Jul 2010
    Location
    Springfield, IL
    Posts
    25
    Sorry to be slow responding; I was tied up and not available. The "what's wrong with the format" is that it wastes too much space. The spacing between each step in the macro is fixed and just wastes too much paper. Just so this makes sense, I have a few macro's that are very big/long. I currently use the Windows 7 Snipping Tool to essentially take a screen snapshot of enough of the macro so that when I paste it into Word, it occupies one page. My word document is 16 pages long. If I just used the Access Database Tools documentor, it would probably be about 40 pages long. When developing the application because of it's complexity, I had to spend a lot of time manually executing each step of the macro to trouble shoot if there was an issue. Whenever I needed to add or delete a step in the macro, I would have to go back to the Snipping Tool, copy each page and paste it into the Word document. It is very time consuming. I hope this makes sense. If there was a way to modify the Database Tools documentor to have it use the equilivant of the "Can Shrink" functions in Access reports, that would be a great first step.

    Chuck

  4. #4
    The VBA Man is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jul 2012
    Posts
    7
    Chuck, try this: (assuming your macro is called "mac", and it's a macro, not a piece of VBA code) 1. Ctrl-G to open the Immediate Window 2. type this: call application.SaveAsText( acMacro, "mac", "C:\mac.txt" ) 3. that's it. the "mac.txt" file is just text

  5. #5
    Join Date
    Jul 2010
    Location
    Springfield, IL
    Posts
    25
    VBA Man, that's great. It worked. I'll need to play around with Word to see about cleaning it up with a Word macro, but its fast and it extracted the information. Do you know how to do the same thing if the macro is a macro embeded within a Command Button on a form? I know I can always edit the Command Button, do a Ctrl-A and Ctrl-C to copy it and then paste it into a new macro but that's an additonal step. Any thoughts?

    Thanks again,
    Chuck

  6. #6
    The VBA Man is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jul 2012
    Posts
    7

    Retrieving text of an embedded macro

    If you have a macro embedded directly in an event property of a control on a form, try this:

    add a command button to the form, or "piggyback" this code to an existing button:
    debug.print me.commandButtonName.Properties("OnClickEmMacro"). value

    assuming that embedded macro was inside the OnClick event.

    of course, you could output this text value anywhere - to a table field, or to a text file

  7. #7
    Join Date
    Jul 2010
    Location
    Springfield, IL
    Posts
    25
    VBA Man, I created a new Command button on the form, "Command189" and on the OnClick event for that new button put: Debug.Print Me.Command56.Properties("OnClickEmMacro").Value Command56 is the button on the form that has the embeded macro that runs when the OnClick event is triggered. When I click on the new command button, nothing happens. Any ideas? Also, I think the real solution is to either append the output to a table or use MakeTable. Then I could write my own Access Report and get it formatted like I would like. Any ideas on that?

    Chuck

  8. #8
    The VBA Man is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jul 2012
    Posts
    7
    Chuck, "debug.print" outputs to the Immediate Window... you can press Ctrl-G to open it. I have a feeling this "macro" is rather long - are you sure it's "embedded" and not a VBA sub or function?

  9. #9
    Join Date
    Jul 2010
    Location
    Springfield, IL
    Posts
    25
    VBA Man, thanks. You were right, the macro data shows up in the Immediate Window, almost immediately. Now, do you know how to take that information and append it to or create a table with it so I can write a report?

    Thanks again,

    Chuck

  10. #10
    The VBA Man is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jul 2012
    Posts
    7
    you can copy that output, then create a temp table with 1 field of "Memo" type, and paste the text into it. then you can write a report based on the table

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Autokey macro will not print reports using a condition
    By boywonder in forum Programming
    Replies: 2
    Last Post: 11-07-2011, 10:48 AM
  2. Replies: 5
    Last Post: 10-26-2011, 02:59 PM
  3. Replies: 0
    Last Post: 02-22-2011, 05:04 AM
  4. Print Preview different from Print Hardcopy
    By peterc in forum Reports
    Replies: 4
    Last Post: 10-27-2009, 05:35 AM
  5. Error when trying to print or print preview
    By TriAdX in forum Reports
    Replies: 8
    Last Post: 08-25-2009, 08:20 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums