How to bypass password when pasting FROM a protected workbook

L

Larry

I can use code to open a password-protected workbook, and copy data
from a worksheet.
However, when I try to paste the data into a unprotected workbook (and
unprotected worksheet),
Excel prompts for a password.

I am very sure this happens at the PASTE stage, because I traced the
issue line by line using the
STOP command to see where the application prompts for the password.

Question is, I have already opened thw workbook by supplyhing the pwd
in the VBA code.
Why does Excel prompts for password before I paste to a UNPROTECTED
worksheet?

How do I avoid this in vba code?

Thanks in advance for your kind help.

Larry
 
G

GS

Larry presented the following explanation :
I can use code to open a password-protected workbook, and copy data
from a worksheet.
However, when I try to paste the data into a unprotected workbook (and
unprotected worksheet),
Excel prompts for a password.

I am very sure this happens at the PASTE stage, because I traced the
issue line by line using the
STOP command to see where the application prompts for the password.

Question is, I have already opened thw workbook by supplyhing the pwd
in the VBA code.
Why does Excel prompts for password before I paste to a UNPROTECTED
worksheet?

How do I avoid this in vba code?

Thanks in advance for your kind help.

Larry

The 'Open' password only allows you to open the file. It has nothing to
do with protection.

As Jim states, workbook protection is separate from worksheet
protection. You must re-apply protection (specifying the
'UserInterfaceOnly:=True' parameter) after a workbook is opened if you
want code to work on protected sheets. The UserInterfaceOnly parameter
does not persist after the workbook is closed, making it a 'runtime
only' option we have to reset every time.
 
L

Larry

Thanks, Jim and Gary,

I'll check whether the worksheet is protected as well.

Cheers,
Larry
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top