ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   HELP! Get error while saving after password protection (https://www.excelbanter.com/excel-programming/348242-help-get-error-while-saving-after-password-protection.html)

Monica

HELP! Get error while saving after password protection
 
If my excel vba code is password protected I will get erros at this line of
code when trying to do a "save as" :

ActiveWorkbook.SaveAs FileName:=CSPath & ActSheet &
CSdata(loop1).csname, FileFormat:=xlTextWindows, Password:= "mypassword",
CreateBackup:=False.

How do I change the code so it can do a save on any excel workbook that
happens to have password protection on the vba project?









Tom Ogilvy

HELP! Get error while saving after password protection
 
It worked fine for me with the project protected (assume the file being
saved isn't the file with the code). Not sure what password protecting a
text file does - for me, it did nothing.

--
Regards,
Tom Ogilvy

"monica" wrote in message
...
If my excel vba code is password protected I will get erros at this line

of
code when trying to do a "save as" :

ActiveWorkbook.SaveAs FileName:=CSPath & ActSheet &
CSdata(loop1).csname, FileFormat:=xlTextWindows, Password:= "mypassword",
CreateBackup:=False.

How do I change the code so it can do a save on any excel workbook that
happens to have password protection on the vba project?











Monica

HELP! Get error while saving after password protection
 
To clarify my situation, the code I posted above is in a VB program, and is
accessing an excel file, which has vba macros in it. Before I ever password
protected my Excel vba projects, the following line of code worked perfectly:

ActiveWorkbook.SaveAs FileName:=CSPath & ActSheet &
CSdata(loop1).csname, FileFormat:=xlTextWindows, CreateBackup:=False.

It seems that an OUTSIDE vb program that tries to do a "save as" on any
protected vba code has problems. NOTE: The workbook and cells are NOT
protected, only the vba project portion, which makes this even more odd.


"Tom Ogilvy" wrote:

It worked fine for me with the project protected (assume the file being
saved isn't the file with the code). Not sure what password protecting a
text file does - for me, it did nothing.

--
Regards,
Tom Ogilvy

"monica" wrote in message
...
If my excel vba code is password protected I will get erros at this line

of
code when trying to do a "save as" :

ActiveWorkbook.SaveAs FileName:=CSPath & ActSheet &
CSdata(loop1).csname, FileFormat:=xlTextWindows, Password:= "mypassword",
CreateBackup:=False.

How do I change the code so it can do a save on any excel workbook that
happens to have password protection on the vba project?













All times are GMT +1. The time now is 12:04 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com