+ Reply to Thread
Results 1 to 9 of 9

Problem writing data to protected worksheets, paste special method fails

  1. #1
    Forum Contributor
    Join Date
    01-11-2013
    Location
    Sweden
    MS-Off Ver
    MS 365
    Posts
    188

    Problem writing data to protected worksheets, paste special method fails

    Hi all,

    Im trying to write data from one workbook to another closed workbook and place the data in first empty row in the closed workbook. This works fine. But when i add a protection to the sheet i want to write data to im running in to problems with placing (pasting) the data. I recive a error 1004 PasteSpecial method of range class failed. When i try to debug it seems like the protection part of the code works like it should. But for some reason im no longer able to paste the data. It works great without the protection.

    Any ideas what im doing wrong?

    Please Login or Register  to view this content.

  2. #2
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,788

    Re: Problem writing data to protected worksheets, paste special method fails

    Try UserInterFaceonly:=True like this...

    Please Login or Register  to view this content.


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  3. #3
    Forum Contributor
    Join Date
    01-11-2013
    Location
    Sweden
    MS-Off Ver
    MS 365
    Posts
    188

    Re: Problem writing data to protected worksheets, paste special method fails

    Hi,

    Thanks for trying to help me. Unfortunately that didnt do the trick. The macro stops on: Range("A64000").End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues

  4. #4
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,788

    Re: Problem writing data to protected worksheets, paste special method fails

    I believe you are applying the sheet protection manually instead of protecting it through vba by marking the userinterface as true.

    Please try and let us know

  5. #5
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Problem writing data to protected worksheets, paste special method fails

    Masun,
    Untested

    Please Login or Register  to view this content.

  6. #6
    Forum Contributor
    Join Date
    01-11-2013
    Location
    Sweden
    MS-Off Ver
    MS 365
    Posts
    188

    Re: Problem writing data to protected worksheets, paste special method fails

    Six, AB

    Thank you very much for you efforts in helping me out!

    Six...I dont understand exactly how you mean. I give the password to the sheet manually in Malfil.xlsm. Then I close it and open the file where i have the range that i want to copy and paste it in to Malfil.xlsm. Do you mean that i Shoud give Malfil.xlsm its password through vba?

    AB... Tried your code but it stops att the "paste row" of the code.

    I think its strange. Without the protection it works perfect. With the protection it dosent work but the part where you unprotect the sheet runs smoothly...

    Any suggestions?

    /Masun

  7. #7
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,788

    Re: Problem writing data to protected worksheets, paste special method fails

    Remove the protection and in Immediate window paste the below

    Please Login or Register  to view this content.
    and press enter which apply protection to the sheet and after that run your macro and check

  8. #8
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Problem writing data to protected worksheets, paste special method fails

    Masun,
    I have now tested the code and it works on my sample data and does not stop anywhere.

  9. #9
    Forum Contributor
    Join Date
    01-11-2013
    Location
    Sweden
    MS-Off Ver
    MS 365
    Posts
    188

    Re: Problem writing data to protected worksheets, paste special method fails

    Guys,

    Thank you! Its working now.

+ 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