+ Reply to Thread
Results 1 to 4 of 4

Type Mismatch in Auto-Open Macro

  1. #1
    Carl Bowman
    Guest

    Type Mismatch in Auto-Open Macro

    I am getting Runtime Error "13" (Type Mismatch) on the following code:
    Sub WorkBook_Open()
    Sheets("Install").Select
    ActiveSheet.Protect password = True
    Sheets("Summary").Select
    End Sub
    When I remove the line "ActiveSheet.Protect password = True" it clears the
    message but I really need this to be done. This is happening in Office 2002
    but not in Office 2000. I can run the command at any time other than opening
    and it does not give the error message. Why does it just do this in the
    Auto-Open macro and what can be done to fix it?
    Thanks.


  2. #2
    Tom Ogilvy
    Guest

    Re: Type Mismatch in Auto-Open Macro

    Your missing a colon:

    Sub WorkBook_Open()
    Sheets("Install").Select
    ActiveSheet.Protect password:=True
    Sheets("Summary").Select
    End Sub

    --
    Regards,
    Tom Ogilvy

    "Carl Bowman" <[email protected]> wrote in message
    news:[email protected]...
    > I am getting Runtime Error "13" (Type Mismatch) on the following code:
    > Sub WorkBook_Open()
    > Sheets("Install").Select
    > ActiveSheet.Protect password = True
    > Sheets("Summary").Select
    > End Sub
    > When I remove the line "ActiveSheet.Protect password = True" it clears the
    > message but I really need this to be done. This is happening in Office

    2002
    > but not in Office 2000. I can run the command at any time other than

    opening
    > and it does not give the error message. Why does it just do this in the
    > Auto-Open macro and what can be done to fix it?
    > Thanks.
    >




  3. #3
    Robin Hammond
    Guest

    Re: Type Mismatch in Auto-Open Macro

    Carl,

    The password part is meant to be a string, not a boolean value and you need
    a colon in there. e.g.

    ActiveSheet.Protect Password:="My Password"

    I'd guess this is working on 2000 because you don't have the Option Explicit
    setting on. Since the first parameter expected is the password, what you are
    doing is setting a password string of "False" which is the evaluation of the
    "password = True" statement.

    Robin Hammond
    www.enhanceddatasystems.com

    "Carl Bowman" <[email protected]> wrote in message
    news:[email protected]...
    >I am getting Runtime Error "13" (Type Mismatch) on the following code:
    > Sub WorkBook_Open()
    > Sheets("Install").Select
    > ActiveSheet.Protect password = True
    > Sheets("Summary").Select
    > End Sub
    > When I remove the line "ActiveSheet.Protect password = True" it clears the
    > message but I really need this to be done. This is happening in Office
    > 2002
    > but not in Office 2000. I can run the command at any time other than
    > opening
    > and it does not give the error message. Why does it just do this in the
    > Auto-Open macro and what can be done to fix it?
    > Thanks.
    >




  4. #4
    Carl Bowman
    Guest

    Re: Type Mismatch in Auto-Open Macro

    Thanks, Tom. You have been a tremendous help!

    "Tom Ogilvy" wrote:

    > Your missing a colon:
    >
    > Sub WorkBook_Open()
    > Sheets("Install").Select
    > ActiveSheet.Protect password:=True
    > Sheets("Summary").Select
    > End Sub
    >
    > --
    > Regards,
    > Tom Ogilvy
    >
    > "Carl Bowman" <[email protected]> wrote in message
    > news:[email protected]...
    > > I am getting Runtime Error "13" (Type Mismatch) on the following code:
    > > Sub WorkBook_Open()
    > > Sheets("Install").Select
    > > ActiveSheet.Protect password = True
    > > Sheets("Summary").Select
    > > End Sub
    > > When I remove the line "ActiveSheet.Protect password = True" it clears the
    > > message but I really need this to be done. This is happening in Office

    > 2002
    > > but not in Office 2000. I can run the command at any time other than

    > opening
    > > and it does not give the error message. Why does it just do this in the
    > > Auto-Open macro and what can be done to fix it?
    > > Thanks.
    > >

    >
    >
    >


+ 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