+ Reply to Thread
Results 1 to 12 of 12

Uploading data to a protect workbook; Unprotect workbook

  1. #1
    Registered User
    Join Date
    07-11-2012
    Location
    Miami, USA
    MS-Off Ver
    Excel 2007
    Posts
    32

    Uploading data to a protect workbook; Unprotect workbook

    Good afternoon Everyone,

    I am running into a error somtimes, "workbook is protected" when the data from workbook1 is uploading into workbook2. Is there a way to get around this so I don't run into this error anymore. The password on workbook2 is 123. I have the code below that I am using to unprotect workbook 2 and them have the data uploaded.

    Please Login or Register  to view this content.
    Thanks,

    Pinstripe

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Uploading data to a protect workbook; Unprotect workbook

    Maybe

    Please Login or Register  to view this content.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    07-11-2012
    Location
    Miami, USA
    MS-Off Ver
    Excel 2007
    Posts
    32

    Re: Uploading data to a protect workbook; Unprotect workbook

    Hi Shg,

    I did try that and it didn't seem to unlock to workbook. I get an error, "run-time error 1004, the password you supplied is incorrect", even though that is the correct password. I have a VBA on the workbook2 that automatically protects the workbook, not sure if it matters when writing the unprotect code.

    Please Login or Register  to view this content.

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Uploading data to a protect workbook; Unprotect workbook

    That code is protecting worksheets, not the workbook. What workbook is that code in?

  5. #5
    Registered User
    Join Date
    07-11-2012
    Location
    Miami, USA
    MS-Off Ver
    Excel 2007
    Posts
    32

    Re: Uploading data to a protect workbook; Unprotect workbook

    That is in workbook2, where the data is uploading into

  6. #6
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Uploading data to a protect workbook; Unprotect workbook

    That shouldn't affect VBA writing to the workbook.What line of code fails, and what is the exact message?

  7. #7
    Registered User
    Join Date
    07-11-2012
    Location
    Miami, USA
    MS-Off Ver
    Excel 2007
    Posts
    32

    Re: Uploading data to a protect workbook; Unprotect workbook

    The line of code that is failing is wbDEST.Unprotect Password:="123". I get an error, "run-time error 1004, the password you supplied is incorrect", even though that is the correct password. The worksheet does not unlock and the code stops

  8. #8
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Uploading data to a protect workbook; Unprotect workbook

    That's my code, not yours. It fails because the workbook is not protected as you said in your first post, the worksheets are, even though the UserInterfaceOnly should not interfere with VBA writing the sheet.

    What line fails in your code, with what message?

  9. #9
    Registered User
    Join Date
    07-11-2012
    Location
    Miami, USA
    MS-Off Ver
    Excel 2007
    Posts
    32

    Re: Uploading data to a protect workbook; Unprotect workbook

    On my line of code, wbDEST.Sheets("New Workbook").Range("C" & Rows.Count).End(xlUp).Offset(1).PasteSpecial xlPasteValues. Would having other excel workbooks open be the problem?

  10. #10
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Uploading data to a protect workbook; Unprotect workbook

    Shouldn't matter that other workbooks are open.

    What is the error message? If it is that the sheet is protected, what happens if you try to unprotect the sheet via the user interface, and then let the code resume?

  11. #11
    Registered User
    Join Date
    07-11-2012
    Location
    Miami, USA
    MS-Off Ver
    Excel 2007
    Posts
    32

    Re: Uploading data to a protect workbook; Unprotect workbook

    The error code i get is, "run-time error 1004, the password you supplied is incorrect". If I unprotect the sheet via the user interface it goes through okay.

  12. #12
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Uploading data to a protect workbook; Unprotect workbook

    That error occurring on the PasteSpecial line makes no sense, and you haven't posted any code that attempts to unprotect the sheet.

+ 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