+ Reply to Thread
Results 1 to 11 of 11

Does UserInterfaceOnly:=True work on closed wb when pasting data to it?

  1. #1
    Forum Contributor
    Join Date
    08-22-2009
    Location
    Manitoba
    MS-Off Ver
    Office 2010
    Posts
    524

    Does UserInterfaceOnly:=True work on closed wb when pasting data to it?

    When copying data from a workbook and pasting it to a closed workbook, does "UserInterfaceOnly:=True" work, or do you have to unlock it then relock the workbook to allow pasting to it? Thanks.

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2406 Win 11 Home 64 Bit
    Posts
    23,949

    Re: Does UserInterfaceOnly:=True work on closed wb when pasting data to it?

    When you say "unlock" and "relock" are you referring to a password protected workbook. I cut and paste monthly a bank statement I receive to a closed workbook and do not unlock it nor use the UserInterfaceOnly functionality.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Forum Contributor
    Join Date
    08-22-2009
    Location
    Manitoba
    MS-Off Ver
    Office 2010
    Posts
    524

    Re: Does UserInterfaceOnly:=True work on closed wb when pasting data to it?

    Quote Originally Posted by alansidman View Post
    When you say "unlock" and "relock" are you referring to a password protected workbook. I cut and paste monthly a bank statement I receive to a closed workbook and do not unlock it nor use the UserInterfaceOnly functionality.
    Yes, but it will not allow me to paste because the workbook is locked until I unlock the cells. In a workbook with code, to change values in locked cells, if you use the UserInterfaceOnly this allows that to happen with code, but doesn't seem to work when pasting to another workbook.

  4. #4
    Forum Expert
    Join Date
    08-17-2007
    Location
    Poland
    Posts
    2,245

    Re: Does UserInterfaceOnly:=True work on closed wb when pasting data to it?

    Quote Originally Posted by thecdnmole View Post
    When copying data from a workbook and pasting it to a closed workbook, does "UserInterfaceOnly:=True" work, or do you have to unlock it then relock the workbook to allow pasting to it?
    It's a bit of a mess here. UserInterfaceOnly is used to protect SHEETS, not BOOKBOOKS. Also, you can't paste a data range into a closed workbook, you need to open it first. Is special protection (UserInterfaceOnly) applied to the closed workbook, or to the workbook from which you will be copying data?
    Assuming that the protection in a special mode applies to a workbook that we will open to paste into it, remember that this mode is volatile. It is important how you open the workbook where you want to paste the data. Do you allow him to run macros or not.

    Please calmly and precisely describe where the special protection is applied (in both workbooks, or only in the target workbook), how you open the target workbook and when the special protection is applied.

    Artik

  5. #5
    Forum Contributor
    Join Date
    08-22-2009
    Location
    Manitoba
    MS-Off Ver
    Office 2010
    Posts
    524

    Re: Does UserInterfaceOnly:=True work on closed wb when pasting data to it?

    describe where the special protection is applied (in both workbooks, or only in the target workbook), how you open the target workbook and when the special protection is applied.
    When opening both workbooks, "UserInterfaceOnly" is applied, but it doesn't allow code to paste to target wb, so I have a line of code to unprotect ws and then protect it once data is pasted. Code opens the target workbook, Set wbData = Workbooks.Open("C:\Users\USER\OneDrive\Documents\Reports.xlsx").

  6. #6
    Forum Expert
    Join Date
    08-17-2007
    Location
    Poland
    Posts
    2,245

    Re: Does UserInterfaceOnly:=True work on closed wb when pasting data to it?

    The Reports.xlsx file has no code, so it cannot have special protection on the sheets. Unless it's a mistake and it should be .xlsm. And one more question if the opened file contains macros. Do you turn off the reaction to events of the following type:
    Please Login or Register  to view this content.
    by running the code for copying the range?

    Artik

  7. #7
    Forum Contributor
    Join Date
    08-22-2009
    Location
    Manitoba
    MS-Off Ver
    Office 2010
    Posts
    524

    Re: Does UserInterfaceOnly:=True work on closed wb when pasting data to it?

    Sorry, should be xlsm, and yes, I turn off events.

  8. #8
    Forum Contributor
    Join Date
    08-22-2009
    Location
    Manitoba
    MS-Off Ver
    Office 2010
    Posts
    524

    Re: Does UserInterfaceOnly:=True work on closed wb when pasting data to it?

    I see my problem, "Application.EnableEvents"! Use it all the time, but was the issue in this case! Thanks.

  9. #9
    Forum Expert
    Join Date
    08-17-2007
    Location
    Poland
    Posts
    2,245

    Re: Does UserInterfaceOnly:=True work on closed wb when pasting data to it?

    But your question was different at the beginning. "When the sheet is in UserUnterfaceOnly mode, can the data be pasted into it using the Copy-Paste method"?
    Answer: No, you can't. You need to unlock the sheet. But...
    You can transfer the data with the method Range.Value = Range.Value. Only values, no formatting. For example:
    Please Login or Register  to view this content.
    I assumed that EnableEvents = True and in the Workbook_Open event (in Target book.xlsm) the target sheet is protected in UserInterfaceOnly mode.

    Artik

  10. #10
    Forum Contributor
    Join Date
    08-22-2009
    Location
    Manitoba
    MS-Off Ver
    Office 2010
    Posts
    524

    Re: Does UserInterfaceOnly:=True work on closed wb when pasting data to it?

    I see, I would prefer to use your code Artik rather than copy and paste. How do I get it to paste in the next available row in the target ws?

  11. #11
    Forum Expert
    Join Date
    08-17-2007
    Location
    Poland
    Posts
    2,245

    Re: Does UserInterfaceOnly:=True work on closed wb when pasting data to it?

    On the forum you will find many examples of calculating the first free row or the last non-empty cell (and the first free row is the last non-empty +1 )

    Artik

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. UserInterfaceOnly:=True still giving protected error
    By LukeNZ in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-02-2020, 01:22 AM
  2. AutoFilter on protected worksheet with userinterfaceonly = true to allow macro use
    By mdaller in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-03-2020, 09:25 PM
  3. [SOLVED] UserInterFaceOnly:=True
    By Frigide in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 07-15-2019, 05:24 AM
  4. Run-time error '1004' despite UserInterfaceOnly = TRUE
    By esbencito in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-10-2018, 06:00 AM
  5. Protect UserInterFaceOnly:=True ONLY to VISIBLE worksheets WITHOUT a password
    By carsto in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-07-2017, 10:20 AM
  6. Worksheet.Protection userinterfaceonly:=true problem
    By Kained in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-23-2009, 04:51 AM
  7. .protect userinterfaceonly:=true not working?
    By dreamz in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-20-2006, 07:31 PM

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