locked
Macro VBA Appcrash error - Excel 2013 RRS feed

  • Question

  • Hello,

    I've been having a problem with a macro for generating passwords for wifi. In Office 2010 there's no problem when running, but in Office 2013 there's the error of Appcrash everytime.

    Anyone had this issue that could help me? is there a problem with the compatiblity in the code with the office 2013?

    There is the code:

                                                                         

    Sub OK()

        'Control that information is provied (nom, compagnie)
        Worksheets("Acceuil").Activate
        Range("D12").Select
        Check1 = ActiveCell.Value
        Range("D15").Select
        Check2 = ActiveCell.Value

        If Check1 <> "" Or Check2 <> "" Then
            Exit Sub
        End If

        'Read names
        Worksheets("Acceuil").Activate
        Range("D11").Select
        NameGuest = ActiveCell.Value
        Range("D14").Select
        CompanyGuest = ActiveCell.Value
        Range("D11").Select

        'Read password
        Workbooks.Open Filename:= _
            "\\Ddns9001\DEPT\Réservations de salles et liste de no de tél. internes\WifiBackup\WifiGuest_backup.xls"
        Windows("WifiGuest_backup.xls").Activate

        Sheets("ListePassword").Visible = True
        Worksheets("ListePassword").Activate
        ActiveSheet.Unprotect "Wifi"
        Range("A1").Select
        AccessCode = ActiveCell.Value

        If AccessCode = "" Then
            MsgBox "Dear " & NameGuest & vbNewLine & "There is no more access code available. Please contact our IT service." & AccessCode & vbNewLine & "Thank you"
            ActiveWindow.Close savechanges:=False
            Exit Sub
        End If

        'Delete password from the list
        Selection.EntireRow.Delete


        'Write data
        Sheets("SuiviAcces").Visible = True
        Worksheets("SuiviAcces").Activate
        ActiveSheet.Unprotect "Wifi"
        Range("A1").Select
        Selection.End(xlDown).Select
        Selection.Offset(1, 0).Select

        ActiveCell.Value = AccessCode
        Selection.Offset(0, 1).Select

        Dim Obj As Object
        Set Obj = CreateObject("WScript.Shell")
        ActiveCell.Value = Obj.SpecialFolders("Desktop")

        Selection.Offset(0, 1).Select
        ActiveCell = NameGuest
        Selection.Offset(0, 1).Select
        ActiveCell = CompanyGuest
        Selection.Offset(0, 1).Select
        ActiveCell = Now
        Selection.Offset(0, 1).Select
        ActiveCell = Now + 7

        Sheets("SuiviAcces").Select
        ActiveSheet.Protect "Wifi"
        ActiveWindow.SelectedSheets.Visible = False
        Sheets("ListePassword").Select
        ActiveSheet.Protect "Wifi"
        ActiveWindow.SelectedSheets.Visible = False

        Application.DisplayAlerts = False
        'ActiveWorkbook.Protect Password:="Wifi"
        ActiveWindow.Close savechanges:=True


        'Informe the acess code
        Worksheets("Acceuil").Activate
        Range("D11").Select
        ActiveCell.Value = ""
        Range("D14").Select
        ActiveCell.Value = ""
        Range("D11").Select

        MsgBox "Dear " & NameGuest & vbNewLine & "Your access code is " & AccessCode & vbNewLine & "Thank you"
        ActiveWindow.Close savechanges:=False

        'Open file
        Workbooks.Open ("\\Ddns9001\DEPT\Réservations de salles et liste de no de tél. internes\WifiBackup\WifiGuest_backup.xls")
        Worksheets("Plan2").Activate

    End Sub

    Thank you very much in advance, Diogo Oliveira

    Monday, March 23, 2015 9:23 AM