+ Reply to Thread
Results 1 to 8 of 8

Macro does not work after the program has been restarted in excel.Run time error 2147417848 (80010108) Method visible of object_worksheet failed

  1. #1

    Macro does not work after the program has been restarted in excel.Run time error 2147417848 (80010108) Method visible of object_worksheet failed

    I have a serious problem which i can not solve. I have buildt a simple
    password login macro in excel making it possible to give different
    users different information.

    The macro works fine when I made it, however After I save it and
    restart it again the above message pops up, when I start the Macro.

    the macro I have made look like this,
    I seems like the macro crash on this line ( Sheets(i).Visible =
    xlSheetVeryHidden)

    Private Sub showAll()
    Dim i As Integer
    For i = 2 To Sheets.Count
    Sheets(i).Visible = xlSheetVisible
    Next i
    End Sub

    Private Sub CommandButton1_Click()
    Dim vPasswords As Variant
    Dim result As String
    Dim i, x As Integer
    Dim arrLength As Integer


    x = 0



    vPasswords = Array("OSLO", "Northern Europe", "FERRARI", "Southern
    Europe", "HEINEKEN", "Central Europe")
    arrLength = UBound(vPasswords) - 1


    For i = 2 To Sheets.Count
    Sheets(i).Visible = xlSheetVeryHidden
    Next i

    result = Application.InputBox(prompt:="Enter password", Type:=2,
    Title:="Port Report 2005")

    If result = "system" Then
    For i = 2 To Sheets.Count
    Sheets(i).Visible = xlSheetVisible
    Next i
    Else

    Do
    If result = "False" Then Exit Sub

    For i = LBound(vPasswords) To UBound(vPasswords) Step 2
    If vPasswords(i) = result Then
    With Sheets(vPasswords(i + 1))
    .Visible = True
    .Activate
    x = x + 1
    End With

    End If

    If i = arrLength Then Exit Do

    Next i

    Loop While True
    If x = 0 Then
    MsgBox "You entered wrong password, please try
    again, If you miss your password pls contact Knut Espegren"
    'Else
    'Sheets(2).Visible = xlSheetVisible
    End If
    End If
    End Sub

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)

    End Sub


    I apprecatie any help with this one as it is driving me crazy!

    Thank you in advance

    Brgds

    Knut


  2. #2

    Re: Macro does not work after the program has been restarted in excel.Run time error 2147417848 (80010108) Method visible of object_worksheet failed

    Hi
    Is the workbook protected? If it is, you will have to remove protection
    before making the sheets hidden or visible (as you are changing the
    workbook).

    regards
    Paul

    [email protected] wrote:
    > I have a serious problem which i can not solve. I have buildt a simple
    > password login macro in excel making it possible to give different
    > users different information.
    >
    > The macro works fine when I made it, however After I save it and
    > restart it again the above message pops up, when I start the Macro.
    >
    > the macro I have made look like this,
    > I seems like the macro crash on this line ( Sheets(i).Visible =
    > xlSheetVeryHidden)
    > ...>
    > Thank you in advance
    >
    > Brgds
    >
    > Knut



  3. #3
    ymze
    Guest

    Re: Macro does not work after the program has been restarted in excel.Run time error 2147417848 (80010108) Method visible of object_worksheet failed

    Hi

    The workbook is not protected...
    The strange thing is that the macro work the second time you try in the
    visual basic modul, without doing any changes.
    this does not work in Excel, as excel freezes when you start the macro
    in excel.

    However I might think that another macro which is running when the
    computer is started might interupt the other macro. I use this macro to
    hide all sheets exept the frontpage where the login function is
    located.
    Can this macro play a part?

    Sub Auto_open()
    Application.Calculation = xlCalculationAutomatic
    Sheets("Login").Visible = xlSheetVisible
    Sheets("Northern Europe").Visible = xlSheetVeryHidden
    Sheets("Central Europe").Visible = xlSheetVeryHidden
    Sheets("Country Overview").Visible = xlSheetVeryHidden
    Sheets("Sales Site").Visible = xlSheetVeryHidden
    Sheets("Sales Port").Visible = xlSheetVeryHidden
    Sheets("Logistics_Info").Visible = xlSheetVeryHidden
    Sheets("Charts_Overview").Visible = xlSheetVeryHidden
    Sheets("Port Sales").Visible = xlSheetVeryHidden
    Sheets("Region Overview").Visible = xlSheetVeryHidden
    Sheets("Chart per Site").Visible = xlSheetVeryHidden
    Sheets("Southern Europe").Visible = xlSheetVeryHidden
    Sheets("Area Overview").Visible = xlSheetVeryHidden
    Sheets("Area per Country").Visible = xlSheetVeryHidden
    Sheets("1").Visible = xlSheetVeryHidden
    Sheets("Port Sales").Visible = xlSheetVeryHidden
    Sheets("Sales Site Calc").Visible = xlSheetVeryHidden
    Sheets("Site Sales").Visible = xlSheetVeryHidden
    Sheets("Hierarchy Port").Visible = xlSheetVeryHidden
    Sheets("hierarchy Acc").Visible = xlSheetVeryHidden
    Sheets("Acc Sales").Visible = xlSheetVeryHidden
    Sheets("Input Port Sales").Visible = xlSheetVeryHidden
    Sheets("Input Acc Sales").Visible = xlSheetVeryHidden
    Sheets("Input Costs").Visible = xlSheetVeryHidden
    Sheets("Input Freight_Agent Costs").Visible = xlSheetVeryHidden
    Sheets("Input inventory").Visible = xlSheetVeryHidden
    Sheets("Input HR").Visible = xlSheetVeryHidden
    Sheets("IDC").Visible = xlSheetVeryHidden
    Sheets("Login").Select
    MsgBox ("Welcome to the Port Report 2005, Login by typing the
    Password for you Area, it is important that you it in Capitol letters,
    if any errors contact Knut Espegren")
    End Sub

    Thank you again for your support!

    Knut


  4. #4
    Tom Ogilvy
    Guest

    Re: Macro does not work after the program has been restarted in excel.Run time error 2147417848 (80010108) Method visible of object_worksheet failed

    Your autoopen macro should be completed when the user is presented the
    msgbox and clicks OK.

    --
    Regards,
    Tom Ogilvy




    "ymze" <[email protected]> wrote in message
    news:[email protected]...
    > Hi
    >
    > The workbook is not protected...
    > The strange thing is that the macro work the second time you try in the
    > visual basic modul, without doing any changes.
    > this does not work in Excel, as excel freezes when you start the macro
    > in excel.
    >
    > However I might think that another macro which is running when the
    > computer is started might interupt the other macro. I use this macro to
    > hide all sheets exept the frontpage where the login function is
    > located.
    > Can this macro play a part?
    >
    > Sub Auto_open()
    > Application.Calculation = xlCalculationAutomatic
    > Sheets("Login").Visible = xlSheetVisible
    > Sheets("Northern Europe").Visible = xlSheetVeryHidden
    > Sheets("Central Europe").Visible = xlSheetVeryHidden
    > Sheets("Country Overview").Visible = xlSheetVeryHidden
    > Sheets("Sales Site").Visible = xlSheetVeryHidden
    > Sheets("Sales Port").Visible = xlSheetVeryHidden
    > Sheets("Logistics_Info").Visible = xlSheetVeryHidden
    > Sheets("Charts_Overview").Visible = xlSheetVeryHidden
    > Sheets("Port Sales").Visible = xlSheetVeryHidden
    > Sheets("Region Overview").Visible = xlSheetVeryHidden
    > Sheets("Chart per Site").Visible = xlSheetVeryHidden
    > Sheets("Southern Europe").Visible = xlSheetVeryHidden
    > Sheets("Area Overview").Visible = xlSheetVeryHidden
    > Sheets("Area per Country").Visible = xlSheetVeryHidden
    > Sheets("1").Visible = xlSheetVeryHidden
    > Sheets("Port Sales").Visible = xlSheetVeryHidden
    > Sheets("Sales Site Calc").Visible = xlSheetVeryHidden
    > Sheets("Site Sales").Visible = xlSheetVeryHidden
    > Sheets("Hierarchy Port").Visible = xlSheetVeryHidden
    > Sheets("hierarchy Acc").Visible = xlSheetVeryHidden
    > Sheets("Acc Sales").Visible = xlSheetVeryHidden
    > Sheets("Input Port Sales").Visible = xlSheetVeryHidden
    > Sheets("Input Acc Sales").Visible = xlSheetVeryHidden
    > Sheets("Input Costs").Visible = xlSheetVeryHidden
    > Sheets("Input Freight_Agent Costs").Visible = xlSheetVeryHidden
    > Sheets("Input inventory").Visible = xlSheetVeryHidden
    > Sheets("Input HR").Visible = xlSheetVeryHidden
    > Sheets("IDC").Visible = xlSheetVeryHidden
    > Sheets("Login").Select
    > MsgBox ("Welcome to the Port Report 2005, Login by typing the
    > Password for you Area, it is important that you it in Capitol letters,
    > if any errors contact Knut Espegren")
    > End Sub
    >
    > Thank you again for your support!
    >
    > Knut
    >




  5. #5
    ymze
    Guest

    Re: Macro does not work after the program has been restarted in excel.Run time error 2147417848 (80010108) Method visible of object_worksheet failed

    ok, thanks. However it doesnt solve the problem

    Do anyone have any ideas?


  6. #6
    Dave Peterson
    Guest

    Re: Macro does not work after the program has been restarted inexcel.Run time error 2147417848 (80010108) Method visible ofobject_worksheet failed

    Is that code in a General module--or is it in ThisWorkbook or one of the sheet
    modules?

    ymze wrote:
    >
    > ok, thanks. However it doesnt solve the problem
    >
    > Do anyone have any ideas?


    --

    Dave Peterson

  7. #7
    ymze
    Guest

    Re: Macro does not work after the program has been restarted in excel.Run time error 2147417848 (80010108) Method visible of object_worksheet failed

    The first code, part 1, (the login function) is part of sheet 1 while
    the rest of the code in the workbook is code in the general module.


  8. #8
    Dave Peterson
    Guest

    Re: Macro does not work after the program has been restarted inexcel.Run time error 2147417848 (80010108) Method visible ofobject_worksheet failed

    auto_open should be in a general module.

    ymze wrote:
    >
    > The first code, part 1, (the login function) is part of sheet 1 while
    > the rest of the code in the workbook is code in the general module.


    --

    Dave Peterson

+ 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