+ Reply to Thread
Results 1 to 9 of 9

Starting a Macro when Command is Executed?

  1. #1
    Registered User
    Join Date
    06-30-2005
    Posts
    61

    Starting a Macro when Command is Executed?

    Is there anyway for me to have a macro run automatically whenever an action is done on Excel? For example, could I set up a macro that saves the file to automatically run whenever I print?

  2. #2
    Bob Phillips
    Guest

    Re: Starting a Macro when Command is Executed?

    You can trap events and fire your macro from there. For instance, there is a
    BeforePrint event. See http://www.cpearson.com/excel/events.htm, it says
    Excel97 but it is still valid.

    --
    HTH

    Bob Phillips

    "Losse" <Losse.1s0gaz_1121094972.5272@excelforum-nospam.com> wrote in
    message news:Losse.1s0gaz_1121094972.5272@excelforum-nospam.com...
    >
    > Is there anyway for me to have a macro run automatically whenever an
    > action is done on Excel? For example, could I set up a macro that saves
    > the file to automatically run whenever I print?
    >
    >
    > --
    > Losse
    > ------------------------------------------------------------------------
    > Losse's Profile:

    http://www.excelforum.com/member.php...o&userid=24813
    > View this thread: http://www.excelforum.com/showthread...hreadid=386133
    >




  3. #3
    Registered User
    Join Date
    06-30-2005
    Posts
    61
    How would I get it to run automatically as soon as an event occurs? I doubt this would work, but could I do something with a similar idea to:

    If Workbook_BeforePrint = true Then
    Call "SaveMacro"
    End If

  4. #4
    Bob Phillips
    Guest

    Re: Starting a Macro when Command is Executed?

    No it would be something like

    Private Sub Workbook_BeforePrint(Cancel As Boolean)
    Call "SaveMacro"
    End Sub

    Read the link I gave you.

    --
    HTH

    Bob Phillips

    "Losse" <Losse.1s0lvi_1121101722.8514@excelforum-nospam.com> wrote in
    message news:Losse.1s0lvi_1121101722.8514@excelforum-nospam.com...
    >
    > How would I get it to run automatically as soon as an event occurs? I
    > doubt this would work, but could I do something with a similar idea
    > to:
    >
    > If Workbook_BeforePrint = true Then
    > Call "SaveMacro"
    > End If
    >
    >
    > --
    > Losse
    > ------------------------------------------------------------------------
    > Losse's Profile:

    http://www.excelforum.com/member.php...o&userid=24813
    > View this thread: http://www.excelforum.com/showthread...hreadid=386133
    >




  5. #5
    Bob Phillips
    Guest

    Re: Starting a Macro when Command is Executed?

    Sorry, meant

    Private Sub Workbook_BeforePrint(Cancel As Boolean)
    Call SaveMacro
    End Sub


    --
    HTH

    Bob Phillips

    "Bob Phillips" <phillips@tiscali.co.uk> wrote in message
    news:uVPDgGkhFHA.1244@TK2MSFTNGP14.phx.gbl...
    > No it would be something like
    >
    > Private Sub Workbook_BeforePrint(Cancel As Boolean)
    > Call "SaveMacro"
    > End Sub
    >
    > Read the link I gave you.
    >
    > --
    > HTH
    >
    > Bob Phillips
    >
    > "Losse" <Losse.1s0lvi_1121101722.8514@excelforum-nospam.com> wrote in
    > message news:Losse.1s0lvi_1121101722.8514@excelforum-nospam.com...
    > >
    > > How would I get it to run automatically as soon as an event occurs? I
    > > doubt this would work, but could I do something with a similar idea
    > > to:
    > >
    > > If Workbook_BeforePrint = true Then
    > > Call "SaveMacro"
    > > End If
    > >
    > >
    > > --
    > > Losse
    > > ------------------------------------------------------------------------
    > > Losse's Profile:

    > http://www.excelforum.com/member.php...o&userid=24813
    > > View this thread:

    http://www.excelforum.com/showthread...hreadid=386133
    > >

    >
    >




  6. #6
    Registered User
    Join Date
    06-30-2005
    Posts
    61
    Thank you. Is there also an event that happens before a macro is run or the macro screen is selected?

  7. #7
    Bob Phillips
    Guest

    Re: Starting a Macro when Command is Executed?

    Which macro, yours or the BeforePrint event?

    --
    HTH

    Bob Phillips

    "Losse" <Losse.1s25hu_1121173780.2124@excelforum-nospam.com> wrote in
    message news:Losse.1s25hu_1121173780.2124@excelforum-nospam.com...
    >
    > Thank you. Is there also an event that happens before a macro is run or
    > the macro screen is selected?
    >
    >
    > --
    > Losse
    > ------------------------------------------------------------------------
    > Losse's Profile:

    http://www.excelforum.com/member.php...o&userid=24813
    > View this thread: http://www.excelforum.com/showthread...hreadid=386133
    >




  8. #8
    Registered User
    Join Date
    06-30-2005
    Posts
    61
    I was referring to when the user goes to tools.>macro. Is there an event before the choices of the macros to select appears?

  9. #9
    Bob Phillips
    Guest

    Re: Starting a Macro when Command is Executed?

    No.

    --
    HTH

    Bob Phillips

    "Losse" <Losse.1s408a_1121260248.2549@excelforum-nospam.com> wrote in
    message news:Losse.1s408a_1121260248.2549@excelforum-nospam.com...
    >
    > I was referring to when the user goes to tools.>macro. Is there an event
    > before the choices of the macros to select appears?
    >
    >
    > --
    > Losse
    > ------------------------------------------------------------------------
    > Losse's Profile:

    http://www.excelforum.com/member.php...o&userid=24813
    > View this thread: http://www.excelforum.com/showthread...hreadid=386133
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1