Hi All,

I need help to combine two different vba codes in order to achieve a desired result.

I want to be able to have a full Excel 2007 screen all through the workbook. The 3 buttons (maximize, restore and close) should also be disabled. I have two different codes to achieve those but because of my baby knowledge in vba, I don't know how to combine the two, and I therefore need help please.

In order to achieve a full screen, I found a code which was kindly provided by a guru member of the forum (RoyUk). I have shown below the two-part code for the full screen, indicating where each part is placed into:

In 'ThisWorkbook'

Option Explicit
Private Sub Workbook_BeforeClose(Cancel As Boolean)
''''''''''''''''''''''''''''''''''''''''''''''''
AppReset (True) '<- AppRest controls Full Screen
End Sub

Private Sub Workbook_Open()
''''''''''''''''''''''''''''''''''''''''''''''''
'Show FullScreen
''''''''''''''''''''''''''''''''''''''''''''''''
AppReset False
End Sub
Private Sub Workbook_Activate()
AppReset (False)
End Sub
Private Sub Workbook_Deactivate()
AppReset (True)
End Sub
In "Module 1"

Option Explicit
Sub AppReset(OK As Boolean)
Application.DisplayFullScreen = Not OK
' ActiveWindow.DisplayHeadings = OK
On Error Resume Next
Application.OnKey "{ESC}", ""
Application.CommandBars("Full Screen").Visible = False
On Error GoTo 0

End Sub
Although the above code achieves full screen, the only thing that still shows is the bar which houses the 3 buttons (minimize, restore and close)

I do not need the 'X' close button. There is a command button (EXIT button) on the first (Menu) sheet which users must use to exit the program. I therefore need to disable the remaining three buttons - the 'X-close button and the minimize and restore close buttons also.

In my search, I also found, and have appended below,a vba code that disables those 3 buttons, as follows:

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Cancel = True
End Sub

Private Sub Workbook_WindowResize(ByVal Wn As Window)
Wn.WindowState = xlMaximized
EnableResize = False
End Sub
My problem is how to combine the two sets of codes.

When I try including this last set of codes in 'ThisWorkbook' along with the fullscreen code above, I get a 'Compile Error - Ambiguous name detected: Workbook before close' message, and I therefore believe I must be doing something wrong. I have also tried placing this last set of codes in a separate Module. I believe it is also wrong cos it doesn't disable the 3 remaining buttons.

For the code that disables the 3 buttons to work, I think that it should go also onto 'ThisWorkbook', but I need help on how to combine it with the 'fullscreen' code above.

Please can someone help me. And if RoyUk will be reading this, I would appreciate his help on how to incorporate the 3-buttons-disable-code to his fullscreen code, please.

Thanks all in anticipation of your kind help.

Newqueen