Results 1 to 4 of 4
  1. #1
    Bronze Lounger
    Join Date
    Sep 2007
    Posts
    1,203
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Always read only (2002)

    The following code still shows the Password dialogue on a protected workbook. I don't want to see the dialogue, but always select read only.

    Application.DisplayAlerts = False
    Set wf = Workbooks.Open(Filename:="C:UsersNathanDocuments08 08misspymnt0808.xls")
    Application.DisplayAlerts = True

    What am I doing wrong?

  2. #2
    5 Star Lounger
    Join Date
    Aug 2004
    Location
    Connecticut, USA
    Posts
    816
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Always read only (2002)

    You would have to either strip off the password on the workbook itself and have it open as read only or you would have to supply the password in the code where your are opening the workbook.

    Application.DisplayAlerts = False
    Set wf = Workbooks.Open(Filename:="C:UsersNathanDocuments08 08misspymnt0808.xls", password:="MyPassword")
    Application.DisplayAlerts = True

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Always read only (2002)

    Use
    <code>
    Set wf = Workbooks.Open(Filename:="C:UsersNathanDocuments08 08misspymnt0808.xls", ReadOnly:=True)
    </code>
    You don't even need to set DisplayAlerts to False and back to True.

  4. #4

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •