简体   繁体   中英

how to save data in password protected workbook vba

I have a workbook with userform, which saves data to remote master workbook. The latter is password protected - set as read only. I am trying to open the workbook as readwrite by using VBA password, however I'm being prompted for a password anyway. Here is my code, could you please guide me, what is it I'm doing wrong? Please help.

Dim wb As Workbook
Dim nr As Long

Set wb = Workbooks.Open("C:\Users\Jasiek\Desktop\Multiple Test\premote.xlsx", Password:="Bartek")
nr = Sheets(1).Range("A" & Rows.Count).End(xlUp).Row + 1

Application wants to save as copy instead of original file, even though the password is typed in manually: 在此处输入图片说明

@Storax Thanks, but the issue still persists. I wrote the code, saved, reopened, copied the code, saved, reopened. After hitting submit I've this: 在此处输入图片说明

Any idea why this might be the case?

Thanks

更改您的Workbook.Open行为follwos Set wb = Workbooks.Open("C:\\Users\\Jasiek\\Desktop\\Multiple Test\\premote.xlsx", WriteResPassword:="Bartek")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM