+ Reply to Thread
Results 1 to 10 of 10

Macros link problem?

  1. #1
    Registered User
    Join Date
    10-16-2006
    Posts
    5

    Macros link problem?

    Hello,

    A project I've inherited is causing me a little headache...


    An old button wich was calling a procedure to quit the excel
    application has been removed. Since that time, whenever a user is
    clicking on any cell (not already linked to a macro), it is calling the
    quitting procedure.


    This procedure is still called elsewhere, so I don't want to get rid of
    it.


    I've tried moving the project to a new workbook but the problem is
    still there!


    Is there any place I can see the link between controls and macros? Or
    do have any ideas what the problem could be?


    Thank you all!

  2. #2
    Forum Expert Simon Lloyd's Avatar
    Join Date
    03-02-2004
    Location
    locked in the cage
    MS-Off Ver
    All the ones my homepage shows
    Posts
    3,161
    The procedure is being called by a 'Change Event' like
    Please Login or Register  to view this content.
    or
    Please Login or Register  to view this content.
    these can be found by looking at the visual basic editor and checking the sheet modules for each sheet and the This WorkBook module, thats the only way by clicking a cell the procedure can be run, if its not a Change Event then it could be a Click Event like
    Please Login or Register  to view this content.
    or
    Please Login or Register  to view this content.
    look in both modules for these.

    Regards,
    Simon

  3. #3
    Registered User
    Join Date
    10-16-2006
    Posts
    5
    Thanks for your response Simon.

    Unfortunately, I've already checked in those events, putting breakpoints, put it wont even go in there. It calls the quitting procedure immediately.

    Even more puzzling, it happens on every machine but one: the only thing different with that one is that windows and office languages are English, as opposed to all the others that are (and have to remain) French. Not sure if that's a factor...

  4. #4
    Forum Expert Simon Lloyd's Avatar
    Join Date
    03-02-2004
    Location
    locked in the cage
    MS-Off Ver
    All the ones my homepage shows
    Posts
    3,161
    Can you post your workbook or code in its entirety?

    Regards,
    Simon

  5. #5
    Registered User
    Join Date
    10-16-2006
    Posts
    5
    Unfortunately, I don't have the rights to post it.

    The key maybe under protection though... maybe a workaround could be done?

    Situation right now is, under the protect sheet option :
    Everything unchecked except "Select unlocked cells"
    -> that works on every sheets but one. but on the PC setted differently (English), works everywhere! I mean, the cursor changes to an hand (showing a macro is assigned) even if there is no macro assigned, but on the other working PC, the cursor is a plus sign (apparently no macros assigned)...

    Them, if I check the "edit objects" on that problematic sheet
    -> now the macro isn't called anymore but the user can drag and resize the objects on the sheet, wich is less of a problem but still not good.

    So when we uncheck "edit objects", the sheet is assigned a macro (quitting procedure) to everywhere on the sheet that doesn't have a macro already assigned to it.

    This is really odd...

    Thanks for your help!

  6. #6
    Forum Expert Simon Lloyd's Avatar
    Join Date
    03-02-2004
    Location
    locked in the cage
    MS-Off Ver
    All the ones my homepage shows
    Posts
    3,161
    I dont understand, if, as i suggested earlier you did view and check the modules for the change event then you have the capability to copy the code to here, its a straight highlight of the code and then paste into your message window!

    regards,
    Simon
    Last edited by Simon Lloyd; 10-18-2006 at 11:15 AM.

  7. #7
    Registered User
    Join Date
    10-16-2006
    Posts
    5
    Hi Simon,

    The point is there is no code at all on the sheet that cause problem (no Worksheet_Change, Worksheet_SelectionChange...)

    There is code in the some other sheets for those events though. I've put breakpoints in every events of every sheets: it doesn't enter any events! It goes directly in that module's procedure. That's why I don't think posting the code would make a difference, but here it is anyway.

    Code in a sheet looks like that:

    Private Sub Worksheet_Change(ByVal Target As Range)
    On Error GoTo ErrHandler
    Const LOCATION As String = NOM_MODULE & "(Worksheet_Change)"

    Application.EnableEvents = False
    Call TestDataEtape1(Target.Row(), Target.Column(), m_intDureeAncien)
    Application.EnableEvents = True

    'Si Première année d'analyse
    If Range(VAR_ET1_TXT_PREMIERE_ANNEE_ANALYSE).Address = Target.Address Then
    'MAJ l'année d'actualisation et l'année retenue pour les $ constant
    Range(VAR_ET1_TXT_PREMIERE_AN_RETENUE_ACTUALISATION) = Target.Value
    Range(VAR_ET1_TXT_PREMIERE_AN_RETENUE_DOL_CONSTANTS) = Target.Value
    G_iModification = 1
    End If

    Exit Sub
    ErrHandler:
    LogErr_Continu LOCATION, "CIP: " & g_strUserNameNT
    End Sub
    '************************************************************************************************************

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    m_intDureeAncien = Range(VAR_ET1_TXT_PREMIERE_DUREE_ANALYSE).Value
    End Sub


    And the procedure that is called directly is:

    Sub QuitterApplication()

    On Error GoTo Err_Header
    Const LOCATION As String = NOM_MODULE & "(QuitterApplication)"

    strActiveSheet = ActiveSheet.Name
    Application.ScreenUpdating = False

    IndAnnulerEnregistrer = False

    If ExistanceFichier(sNameFile) = True Then
    reponse = MsgBox(QST_PROJETOUVERT_ENREGISTREMENT, vbQuestion + vbYesNoCancel, "Enregistrer le projet?")
    If reponse = vbYes Then
    Call EnregistrerSous
    End If
    '**************************************************************************************
    'Ajout pour supprimer la double confirmation de sauvegarde
    If reponse <> vbCancel Then
    Workbooks(sNameFile).Saved = True
    Workbooks(sNameFile).Close
    End If
    'Remplace
    '**************************************************************************************
    'If reponse <> vbCancel Then Workbooks(sNameFile).Close
    '**************************************************************************************
    If reponse = vbCancel Then IndAnnulerEnregistrer = True
    End If

    If IndAnnulerEnregistrer = True Then
    Workbooks(Sheets("Parametres").Cells(1, 1).Value).Activate
    Sheets(strActiveSheet).Select
    Exit Sub
    Else
    Workbooks(Sheets("Parametres").Cells(1, 1).Value).Activate

    Call InitialisationNomProjet("")
    Call InitialisationEtape1
    Sheets("Menu Principal").Select
    Sheets("Menu Principal").Unprotect Password:=PASSWORD_PROTECTION
    Sheets("Menu Principal").Range("varNomVariante").Value = ""
    If Worksheets(1).DropDowns("varCboNomVariante").ListIndex <> 0 Then
    Worksheets(1).DropDowns("varCboNomVariante").ListIndex = 0
    End If
    Sheets("Menu Principal").Protect Password:=PASSWORD_PROTECTION
    Call AfficherEtapeNavigateur("Etape3", True)
    Call AfficherEtapeNavigateur("Etape6", True)

    Cells(1, 1).Select
    Application.ScreenUpdating = True
    Application.ScreenUpdating = False
    End If

    Application.OnKey "^{PGUP}"
    Application.OnKey "^{PGDN}"

    DetectionModificationDesactive

    Workbooks(Sheets("Parametres").Cells(1, 1).Value).Activate
    Sheets("Menu Principal").Select
    Application.DisplayAlerts = False

    Application.Quit

    Exit Sub

    Err_Header:

    If Err.Number = 424 Then
    Resume Next
    End If
    LogErr_Continu LOCATION, "CIP: " & g_strUserNameNT

    End Sub




    I really apreciate you trying to help. I think this has something to do with some windows settings because, as mentionned earlier, it doesn't cause that problem on every machine

    THANKS!

  8. #8
    Forum Expert Simon Lloyd's Avatar
    Join Date
    03-02-2004
    Location
    locked in the cage
    MS-Off Ver
    All the ones my homepage shows
    Posts
    3,161
    Well i took a look, shame i cant understand french very well, i dont know if the windows environment can directly affect the excel worksheet, however you could try this in the quitter module
    [vba]Const LOCATION As String = NOM_MODULE & "(QuitterApplication)"
    If MsgBox("Do you really want to quit?", vbYesNo, "Quit Confirmation") = vbNo Then
    Exit Sub
    Else: 'THE REST OF THE CODE HERE'
    End If
    [/vba]the coloured code is what i would have added to allow a choice before quitting!

    regards,
    Simon

  9. #9
    Registered User
    Join Date
    10-16-2006
    Posts
    5
    Yeah, sorry about the french procedure names.

    Your idea was not bad but the interaction with the user is not acceptable.

    BUT you made me think of a solution, and it works!!!!

    I've added an optional parameter to verify if the call to the procedure was an "authorized" one, and made it quit the procedure if it wasn't.

    Sub QuitterApplication(Optional ValidCall As Boolean = False)

    If Not ValidCall Then Exit Sub


    Then for every call in the program, I just set the optional parameter to true:

    QuitterApplication True

    Et voilà!!!!!

    That was weird but now the beast is finally under control!

    Thanks!

  10. #10
    Forum Expert Simon Lloyd's Avatar
    Join Date
    03-02-2004
    Location
    locked in the cage
    MS-Off Ver
    All the ones my homepage shows
    Posts
    3,161
    Cool!, glad your sorted!

    regards,
    Simon

+ 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