Results 1 to 10 of 10
  1. #1
    3 Star Lounger
    Join Date
    Feb 2003
    Posts
    363
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Why 2 clicks to run macro (2000)

    I have an Addin wbk that opens and acts on wbk gsFILE_RENTAL_APPL.
    Wbk gsFILE_RENTAL_APPL has 3 Forms cmd buttons.
    Each button has a corresponding macro found in my addin.

    Two macros work as expected.

    However, the "Exit" button has a quirk: the first time I click it, the screen (or rather the active cell flickers).
    The second time I click it, the following code runs.

    I have replaced the line -- "On error resume next"
    with: "Stop" to test it and stepped thru the code.
    There were no errors. Also, when the "Stop" was
    in place, I clicked the button and just the same flicker on the first click, then on the second click
    it ran to the Stop as expected.

    Question: what is happening on click one? Why doesn't it run the macro?

    <pre> Public Sub ShutdownApplication()

    ' Ignore any errors during shutdown.
    On Error Resume Next

    '' Set the closing flag ( to avoid looping if user
    '' has clicked the "X" button.
    gbShutdownInProgress = True

    With Application
    .DisplayFormulaBar = True

    'Close the DataEntry wbk
    .Workbooks(gsFILE_RENTAL_APPL).Close False

    'Restore the state of the Excel environment to
    Call RestoreExcelSettings

    ' If there are no workbooks left open, quit Excel.
    ' Otherwise just close this workbook.
    If lCountVisibleWorkbooks() = 0 Then
    ThisWorkbook.Saved = True
    .Quit
    Else
    ThisWorkbook.Close False
    End If
    End With
    End Sub
    </pre>


  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Why 2 clicks to run macro (2000)

    There is probably some kind of interference with other pieces of code in your add-in. Do you have worksheet-level, workbook-level or application-level event handlers?

  3. #3
    3 Star Lounger
    Join Date
    Feb 2003
    Posts
    363
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Why 2 clicks to run macro (2000)

    I only have 2 event handlers, neither seem to apply to the clicking of a cmd button. They are:
    1. Workbook_Open in the Wbk module
    2. Worksheet_SelectionChange

    I'm not opening any wbk.
    Since I'm not changing a selection in the worksheet, I don't see how this would apply.
    But here is the code:
    <pre>Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Target.Count > 1 Then Exit Sub
    Application.EnableEvents = False

    If Not Intersect(Target, Range("FullName").Offset(1, 0)) Is Nothing Then
    ActiveWindow.ScrollRow = "108"
    GoTo ShutDown
    End If

    If Not Intersect(Target, Range("FullName").Offset(2, 0)) Is Nothing Then
    Range("FullName").Offset(1, 0).Select
    GoTo ShutDown
    End If


    ShutDown:
    Application.EnableEvents = True
    End Sub
    </pre>


  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Why 2 clicks to run macro (2000)

    I'm afraid that nothing jumps out at me.

    Can you test the add-in/workbook combination on another PC?

  5. #5
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Why 2 clicks to run macro (2000)

    It sounds like that code is attached to the worksheet beforedoubleclick event routine and not to a button. Hard to tell without seeing the workbook. Could you delete everything from the workbook that is not needed to see the problem and upload it?
    Legare Coleman

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Why 2 clicks to run macro (2000)

    Clicking each of the three buttons results - the first time! - in a message starting with 'RentalAppAddIn.xla' could not be found.

  7. #7
    3 Star Lounger
    Join Date
    Feb 2003
    Posts
    363
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Why 2 clicks to run macro (2000)

    <P ID="edit" class=small>(Edited by GoCush on 12-May-05 11:56. Commented out last line of Workbook_Open code)</P>Legare,
    It kind of sounds that way but thats not the case. First, I'm not double clicking - this is two separate clicks - could be five minutes apart.

    This has me baffled.
    See attached file

    Thanks for the help

  8. #8
    3 Star Lounger
    Join Date
    Feb 2003
    Posts
    363
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Why 2 clicks to run macro (2000)

    The code for each button resides in the Addin. I sent the first attached file to see the code in the two object modules
    I am now attaching a txt file which contains the applicable code from the Addin.
    All of this code is found in a standard module.
    There is no code in the object modules of the Addin.

    Hope this helps.

  9. #9
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Why 2 clicks to run macro (2000)

    That doesn't help much. The worksheet is protected with a password.

  10. #10
    3 Star Lounger
    Join Date
    Feb 2003
    Posts
    363
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Why 2 clicks to run macro (2000)

    Sorry.
    Let me see if I can assemble this in a more testable format.

Posting Permissions

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