Home |
Search |
Today's Posts |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Just came across this issue in Excel 2007 as well.
The problem we were having was that you couldn't add a worksheet or delete a worksheet. Using this solution seemed to work. "bta" wrote: If TargetWorkbook Is ActiveWorkbook, a work-around is to execute the builtin command bar control "File Save" instead of TargetWorkbook.Save Here a code example: 'http://support.microsoft.com/kb/213552 Const id_menu_item_SAVE As Long = 3 Const id_menu_item_SAVE_AS As Long = 748 Const id_menu_main_FILE As Long = 30002 Const title_worksheet_menu_bar As String = "Worksheet Menu Bar" Dim builtin_save As CommandBarControl Dim builtin_save_as As CommandBarControl Private Sub FindSomeBuiltinCommands() Dim menu_item As CommandBarControl Dim popup_menu As CommandBarPopup Set popup_menu = Application.CommandBars(title_worksheet_menu_bar). FindControl(Type:=msoControlPopup, ID:=id_menu_main_FILE) For Each menu_item In popup_menu.Controls If menu_item.ID = id_menu_item_SAVE Then Set builtin_save = menu_item If menu_item.ID = id_menu_item_SAVE_AS Then Set builtin_save_as = menu_item Next End Sub Private Sub DoSave() Call builtin_save.Execute ' When using "Call ThisWorkbook.Save" instead, "Worksheet.Unprotect/.Protect" does NOT work !!! End Sub Private Sub TEST() Call FindSomeBuiltinCommands Call DoSave End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Worksheet.Unprotect within WorkbookBeforeSave event fails if Save initiated by VB | Excel Programming | |||
Macro to Unprotect save worksheet and protect it again. | Excel Programming | |||
event after worksheet unprotect | Excel Programming | |||
Worksheet Save Event | Excel Programming | |||
Save As - Multiple Sheets fails to save as text file | Excel Programming |