+ Reply to Thread
Results 1 to 1 of 1

"The "sheets" method from the "_Global" object have failed."

  1. #1
    Registered User
    Join Date
    10-08-2011
    Location
    malaysia
    MS-Off Ver
    Excel 2003
    Posts
    15

    Unhappy "The "sheets" method from the "_Global" object have failed."

    I have a excel file in a webserver, and the users must run it
    directly from the internet explorer.

    The problem is : when a user click over the excel table link it opens
    the excel in internet explorer but when he/she clicks to run the macro
    the macro give some sheet errors.

    "The "sheets" method from the "_Global" object have failed."


    I dont know why this happen, when the user download and then run
    the macro works great, but in internet explorer the macro turns crazy.

    Option Explicit

    Private Sub Cancel_Click()

    Unload Me

    End Sub

    Private Sub OK_Click()

    Dim c As Object
    Dim UserName As String
    Dim Password As String
    Dim MyError As Integer

    'Assign UserName to a variable
    UserName = UserVerification.UserName.Text

    'Assign Password to a variable
    Password = UserVerification.Password.Text

    'Specify the sheet and range to look up the UserName
    With Sheets("Uniformity Check").Range("BQ:BQ")
    Set c = .Find(What:=UserName, LookIn:=xlValues, lookat:=xlWhole, MatchCase:=True)
    End With

    'If UserName cannot be found
    If c Is Nothing Then
    MsgBox "The username you have enterd is invalid, please try again.", vbCritical, "Incorrect UserName"
    Exit Sub
    End If

    'If Password is correct
    If Password = Sheets("Uniformity Check").Range(c.Address).Offset(0, 1).Text Then
    ThisWorkbook.Unprotect Password:="mankit_chung"
    Sheets("Uniformity Check").Select
    ActiveSheet.Unprotect Password:="mankit_chung"
    Range("C6").Select
    ActiveCell.FormulaR1C1 = UserName
    'If the sheet to make visible is not in the workbook an error will occur
    'If there is no error then make that sheet visible
    On Error Resume Next
    Sheets(Range(c.Address).Offset(0, 2).Text).Visible = True
    MyError = Err
    On Error GoTo 0
    ThisWorkbook.Protect Password:="mankit_chung", Structure:=True

    'If there was an error let the user know to try again.
    If MyError <> 0 Then
    MsgBox "The password you have specified is incorrect, please try again.", vbCritical, "Incorrect Password"
    Exit Sub
    End If
    Else

    'If the password is incorrect let the user know to try again
    MsgBox "The password you have specified is incorrect, please try again.", vbCritical, "Incorrect Password"
    Exit Sub
    End If

    'Dismiss the userform
    Unload Me
    Call uv_uniformity_check

    End Sub

    Private Sub UserForm_Click()

    End Sub
    Last edited by mankit87; 10-08-2011 at 09:06 AM.

+ 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