E
Elena
I am trying to diable the users ability to save the document upon exit. I
want them to be required to save the file under a different name.
The code works, yet when I put in my .NET application, upon closing the
form, it allows the user to Save instead of Save As.
Here's the code I have below:
Private Sub workbook_open()
'With CommandBars("File")
With Me.Application.CommandBars("File")
..Controls(4).Enabled = False 'Save Button
End With
Me.Application.CommandBars("standard").Controls("Save").Enabled = False
Application.CommandBars("Worksheet Menu Bar").FindControl _
(ID:=748, Recursive:=True).OnAction = "Macro1"
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
With Me.Application.CommandBars("File")
.Controls(4).Enabled = True
End With
Me.Application.CommandBars("Standard").Controls("Save").Enabled = True
strAnswer = MsgBox("Would you like to save the Expense Report?",
vbYesNoCancel)
If strAnswer = vbYes Then
Application.Dialogs(xlDialogSaveAs).Show "C:\New_Expense_Report.xls"
Else
Exit Sub
End If
Application.CommandBars("Worksheet Menu Bar").FindControl _
(ID:=748, Recursive:=True).OnAction = ""
End Sub
Sub Macro1()
Application.Dialogs(xlDialogSaveAs).Show "C:\New_Expense_Report.xls"
End Sub
Any advice would be greatly appreciated!
Thanks,
Elena
want them to be required to save the file under a different name.
The code works, yet when I put in my .NET application, upon closing the
form, it allows the user to Save instead of Save As.
Here's the code I have below:
Private Sub workbook_open()
'With CommandBars("File")
With Me.Application.CommandBars("File")
..Controls(4).Enabled = False 'Save Button
End With
Me.Application.CommandBars("standard").Controls("Save").Enabled = False
Application.CommandBars("Worksheet Menu Bar").FindControl _
(ID:=748, Recursive:=True).OnAction = "Macro1"
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
With Me.Application.CommandBars("File")
.Controls(4).Enabled = True
End With
Me.Application.CommandBars("Standard").Controls("Save").Enabled = True
strAnswer = MsgBox("Would you like to save the Expense Report?",
vbYesNoCancel)
If strAnswer = vbYes Then
Application.Dialogs(xlDialogSaveAs).Show "C:\New_Expense_Report.xls"
Else
Exit Sub
End If
Application.CommandBars("Worksheet Menu Bar").FindControl _
(ID:=748, Recursive:=True).OnAction = ""
End Sub
Sub Macro1()
Application.Dialogs(xlDialogSaveAs).Show "C:\New_Expense_Report.xls"
End Sub
Any advice would be greatly appreciated!
Thanks,
Elena