none
Script works in Pennsylvania...but not in France RRS feed

  • Question

  • Getting a report of "Erreur d'execution '5': Argumen ou appel de procedure incorrect" from a user on French Excel 2010. Running the code on english 2007 and 2010 works fine...

    The error occurs when the user clicks our "save/quit" button on the ribbon, is it possible that any of the VBA commands here are named something different in the french version? The error would suggest i'm calling something incorrectly for his version.

    Translated error: Execution error '5': Argument or Invalid procedure call

    CODE:

    'This procedure closes the application but calls the save dialog first
    Sub btnFileExit_click(control As IRibbonControl)

        'suppress default excel prompts
        Application.DisplayAlerts = False

        'ask if user wants to save, if save is applicable
        Dim response As Integer
        If modPrimary.Mode <> "r" And ThisWorkbook.Saved = False Then
            response = MsgBox("Would you like to save your changes?", vbYesNoCancel, "Save Changes")
        Else
            response = vbNo
        End If

        'if no, disregard any changes. if yes, save changes, hide sheets and display message.
        If response = vbNo Then
            ThisWorkbook.Saved = True
        ElseIf response = vbYes Then
            'display macro warning and hide sheets
            Sheets("Home").lblWarning.Visible = True
            modPrimary.HideAllSheets
           
            'protect workbook structure
            ThisWorkbook.Protect modPrimary.RecordPassword, True, False
           
            'protect home
            Sheets("Home").Protect password:=modPrimary.RecordPassword
           
            'save workbook then quit
            ThisWorkbook.Save
        Else
            're-enable excel prompts
            Application.DisplayAlerts = True
            Cancel = True
            Exit Sub
        End If

        're-enable application items
        With Application
            .CellDragAndDrop = True
        End With

        'disable sheet commands
        Application.CommandBars("Ply").FindControl(ID:=847).Enabled = True 'enable delete sheet
        Application.CommandBars("Ply").FindControl(ID:=945).Enabled = True 'enable insert worksheet
        Application.CommandBars("Ply").FindControl(ID:=889).Enabled = True 'enable rename worksheet
       
        'disable move or copy action
        Application.CommandBars("Ply").Controls("&Move or Copy...").Enabled = True
        Application.CommandBars("Edit").Controls("&Move or Copy Sheet...").Enabled = True
       
        'enable Ply bar
        CommandBars("Ply").Enabled = True
       
        'enable autosave
        Application.AutoRecover.Enabled = True
       
        'restore quick keys
        Call modPrimary.RestoreHotkeys
       
        'close excel
        ThisWorkbook.pClose = True
        Application.Quit
    End Sub

    Tuesday, November 8, 2011 10:09 PM

Answers

  • I can't see anything obvious that would trip up a non-English version, but what's ThisWorkbook.pClose, some method of yours in the ThisWorkbook class.

    There are several calls to modPrimary so maybe there's something in one of those which you haven't posted.

    Which line does the error occur on?

    Peter Thornton

    Wednesday, November 9, 2011 1:06 PM
    Moderator
  • Hi,

    Got to say the whole language / culture difference might be a massive red herring.

    It would help to know what line the error happens on but it could be, for example, that the Command Bar 'Ply' isn't there in the French version. Could be something like that.... a difference in the two versions that isn't down to language. You wight want to add code that says if the Command Bar Ply exists do something with it. 

    Or if it were language issue then it might be that the Home sheets name has actually been changed by a user to Maison since the French language is pure and does not need to be spoilt with your filthy English.

     


    "The programmer, like the poet, works only slightly removed from pure thought-stuff. He builds his castles in the air, from air, creating by exertion of the imagination." - Fred Brooks
    Wednesday, November 9, 2011 1:19 PM

All replies

  • Getting a report of "Erreur d'execution '5': Argumen ou appel de procedure incorrect" from a user on French Excel 2010. Running the code on english 2007 and 2010 works fine...

    The error occurs when the user clicks our "save/quit" button on the ribbon, is it possible that any of the VBA commands here are named something different in the french version? The error would suggest i'm calling something incorrectly for his version.

    Translated error: Execution error '5': Argument or Invalid procedure call

    CODE:

    'This procedure closes the application but calls the save dialog first
    Sub btnFileExit_click(control As IRibbonControl)
    
        'suppress default excel prompts
        Application.DisplayAlerts = False
    
        'ask if user wants to save, if save is applicable
        Dim response As Integer
        If modPrimary.Mode <> "r" And ThisWorkbook.Saved = False Then
            response = MsgBox("Would you like to save your changes?", vbYesNoCancel, "Save Changes")
        Else
            response = vbNo
        End If
    
        'if no, disregard any changes. if yes, save changes, hide sheets and display message.
        If response = vbNo Then
            ThisWorkbook.Saved = True
        ElseIf response = vbYes Then
            'display macro warning and hide sheets
            Sheets("Home").lblWarning.Visible = True
            modPrimary.HideAllSheets
            
            'protect workbook structure
            ThisWorkbook.Protect modPrimary.RecordPassword, True, False
            
            'protect home
            Sheets("Home").Protect password:=modPrimary.RecordPassword
            
            'save workbook then quit
            ThisWorkbook.Save
        Else
            're-enable excel prompts
            Application.DisplayAlerts = True
            Cancel = True
            Exit Sub
        End If
    
        're-enable application items
        With Application
            .CellDragAndDrop = True
        End With
    
        'disable sheet commands
        Application.CommandBars("Ply").FindControl(ID:=847).Enabled = True 'enable delete sheet
        Application.CommandBars("Ply").FindControl(ID:=945).Enabled = True 'enable insert worksheet
        Application.CommandBars("Ply").FindControl(ID:=889).Enabled = True 'enable rename worksheet
        
        'disable move or copy action
        Application.CommandBars("Ply").Controls("&Move or Copy...").Enabled = True
        Application.CommandBars("Edit").Controls("&Move or Copy Sheet...").Enabled = True
        
        'enable Ply bar
        CommandBars("Ply").Enabled = True
        
        'enable autosave
        Application.AutoRecover.Enabled = True
        
        'restore quick keys
        Call modPrimary.RestoreHotkeys
        
        'close excel
        ThisWorkbook.pClose = True
        Application.Quit
    End Sub
    kevile is offline Reply With Quote

    • Merged by Mike Feng Thursday, November 10, 2011 7:24 AM keep them in same topic
    Tuesday, November 8, 2011 9:30 PM
  • Hello Joe4545,

    Welcome to Msdn Forums , if you use vba code with Excel , you can ask your question in dedicated Forum Excel vba , follow link below.

    http://social.msdn.microsoft.com/Forums/it-IT/isvvba/threads

    Best Regards.


    Carmelo La Monica

    Blog http://community.visual-basic.it/carmelolamonica/

    WordPress http://carmelolamonica.wordpress.com/

    Twitter http://twitter.com/carmelolamonica

    Tuesday, November 8, 2011 9:53 PM
  • Thank you Carmelo!  - Joe
    Tuesday, November 8, 2011 10:06 PM
  • Hello Joe4545,
    Thank you Carmelo! - Joe

    You're Welcome.
    Best Regards.

    Carmelo La Monica
    Tuesday, November 8, 2011 10:08 PM
  • I can't see anything obvious that would trip up a non-English version, but what's ThisWorkbook.pClose, some method of yours in the ThisWorkbook class.

    There are several calls to modPrimary so maybe there's something in one of those which you haven't posted.

    Which line does the error occur on?

    Peter Thornton

    Wednesday, November 9, 2011 1:06 PM
    Moderator
  • Hi,

    Got to say the whole language / culture difference might be a massive red herring.

    It would help to know what line the error happens on but it could be, for example, that the Command Bar 'Ply' isn't there in the French version. Could be something like that.... a difference in the two versions that isn't down to language. You wight want to add code that says if the Command Bar Ply exists do something with it. 

    Or if it were language issue then it might be that the Home sheets name has actually been changed by a user to Maison since the French language is pure and does not need to be spoilt with your filthy English.

     


    "The programmer, like the poet, works only slightly removed from pure thought-stuff. He builds his castles in the air, from air, creating by exertion of the imagination." - Fred Brooks
    Wednesday, November 9, 2011 1:19 PM
  • I agree with both answers, also I miss Error handling in above code, that would help as well, locating the error.

     


    Daniel van den Berg | Washington, USA | "Anticipate the difficult by managing the easy"
    Wednesday, November 9, 2011 5:23 PM
    Moderator