Error Checking in Excel
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 3 of 3

Thread: Problem with Opening Workbook

  1. #1
    New Member
    Join Date
    Mar 2002
    Posts
    15
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Hello,

    I have written a macro to automate some monotonous tasks. One of the workbooks opened by the macro is password protected. In the VBA of my macro, I open the workbook using the line
    Workbooks.Open FileName:="filename.xls"
    and enter the password at the prompt. No problem so far, hmm?

    The problem occurs when changes have been made to this workbook by the macro and I want to save it and close it. Excel tells me now that the workbook is opened as "Read-Only" and I cannot save it.

    Any suggestions?

    Thanks,
    StrangeLuck

  2. #2
    Board Regular
    Join Date
    Apr 2002
    Location
    Surrey, United Kingdom
    Posts
    75
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Hi,

    Not sure if this will work as I cannot test it at the moment, but off the top of my head you could try this:

    If ActiveWorkbook.ReadOnly Then
    ActiveWorkbook.SaveAs fileName:="NEWFILE.XLS"
    End If

    If you set the filename as the name it already has, then it should write over itself with the new version. Check out 'ReadOnly' in the VBE help.

    Nibbs

  3. #3
    New Member
    Join Date
    Mar 2002
    Posts
    15
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Alas, the problem is that the macro does not close the password protected workbook, as the user must check over the workbook to make sure that the changes made to it are correct.

    Still, when the workbook is opened by:Workbooks.Open FileName:="filename.xls", ReadOnly:=False
    the file is still shown as being read-only.

    What gives? Any helpers?

    Thanks,
    StrangeLuck


    [ This Message was edited by: StrangeLuck on 2002-05-09 11:16 ]

Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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