jiura
05-01-2008, 12:40 AM
Hello to all!
I want my workbook hide three sheets when it closed. I qrite such code:
Application.ActiveWorkbook.Unprotect Password:=SheetPaswordPr
Sheets("1").Visible = False
Sheets("2").Visible = False
Sheets("3").Visible = False
Application.ActiveWorkbook.Protect Password:=SheetPaswordPr
All works right when one Excel file is open. But when there are two excel files (my file and one more). And my file is not Active. THen If user clicks on cross witch close all excel workbooks, excel shows an error: "Subscribt out of range". How I must correct my code?
I want my workbook hide three sheets when it closed. I qrite such code:
Application.ActiveWorkbook.Unprotect Password:=SheetPaswordPr
Sheets("1").Visible = False
Sheets("2").Visible = False
Sheets("3").Visible = False
Application.ActiveWorkbook.Protect Password:=SheetPaswordPr
All works right when one Excel file is open. But when there are two excel files (my file and one more). And my file is not Active. THen If user clicks on cross witch close all excel workbooks, excel shows an error: "Subscribt out of range". How I must correct my code?