Can't Close Excel

Pullingmyhairout

New Member
Joined
Apr 7, 2016
Messages
29
Good Evening,

Hoping someone can assist me. I have put putting together an excel spread sheet and have been using some VBA code. I am a novice amongst novices and have gathered all the code from around the web and it does exactly as i need and works perfectly.

I used excel 2010 to create my spreadsheet and everything works fine...the issue is if I open the file using excel 2013 (haven't tried 2016) I can not use the x to close the program even if i disable the vba code that hides the ribbon. The only time i'm able to use the X to close out of the program is if i navigate to the very first sheet.

All help is appreciated. thank you.

A link to my excel file is below

https://www.dropbox.com/s/2hlfwefksom3be9/Book8.7.xlsm?dl=0
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".

mole999

Moderator
Joined
Oct 23, 2004
Messages
10,524
Office Version
  1. 2019
  2. 2016
  3. 2013
Platform
  1. Windows
would guess you have something in workbook open event
 

Michael M

Well-known Member
Joined
Oct 27, 2005
Messages
20,540
Office Version
  1. 2016
  2. 2013
  3. 2007
Platform
  1. Windows
I'm sure as heck not going to download a file that simply shows me a button to click on !!!
You need to post the code / s you are using, specifically, as mole has suggested the workbook_open event, or any other workbook / worksheet events
 

ybr_15

Board Regular
Joined
May 24, 2016
Messages
194
Office Version
  1. 2019
  2. 2013
Platform
  1. Windows
I think his problem is this code:
Code:
Application.EnableCancelKey = xlDisabled
When he run a macro button (go to selected sheet), then the code above running and he has set the code in Workbook_Activate & Wokbook_Deactivate too. Just FYI (I am not expert about this) if eveyone here want help this man..hehe;)

NB: the Ribbon is disabled too, so the windows just show minimize, maximize and close button in right corner
 

Michael M

Well-known Member
Joined
Oct 27, 2005
Messages
20,540
Office Version
  1. 2016
  2. 2013
  3. 2007
Platform
  1. Windows
my luck....I'd get the WannaCry ransomware :oops:
 

MrIfOnly

Active Member
Joined
Nov 10, 2016
Messages
492

ADVERTISEMENT

That is some scary sh*t!
 

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
37,118
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2010
Platform
  1. Windows
  2. MacOS
I used excel 2010 to create my spreadsheet and everything works fine...the issue is if I open the file using excel 2013 (haven't tried 2016) I can not use the x to close the program even if i disable the vba code that hides the ribbon.

Upon opening your workbook, I can click the X to close it in both 2013 and 2016.
 

Pullingmyhairout

New Member
Joined
Apr 7, 2016
Messages
29
I'm sure as heck not going to download a file that simply shows me a button to click on !!!
You need to post the code / s you are using, specifically, as mole has suggested the workbook_open event, or any other workbook / worksheet events

This is the relevant code I am using and the button is to allow the users to navigate to different sheets as work tabs are disabled
Code:
Private Sub Workbook_Open()
Worksheets("Pick One Below").Activate
 
Dim TymeOfDay$
If Time < 0.5 Then
TymeOfDay = "Good Morning !!" & vbCrLf & vbCrLf
ElseIf Time >= 0.5 And Time < 0.75 Then
TymeOfDay = "Good Afternoon !!" & vbCrLf & vbCrLf
Else
TymeOfDay = "Good Evening !!" & vbCrLf & vbCrLf
End If
MsgBox _
TymeOfDay & _
"Message" & vbCrLf & _
"Message," & vbCrLf & _
"Message.", 64, "Box Name:"
End Sub
Private Sub Workbook_Activate()
Application.ScreenUpdating = False
Application.ExecuteExcel4Macro "SHOW.TOOLBAR(""Ribbon"",False)" 'False to deactivate
Application.DisplayFormulaBar = False
Application.DisplayStatusBar = Not Application.DisplayStatusBar
ActiveWindow.DisplayWorkbookTabs = False 'True to deactivate
ActiveWindow.DisplayHorizontalScrollBar = False 'True to deactivate
ActiveWindow.DisplayHeadings = False 'True to deactivate
Application.ScreenUpdating = True
Sheets("Released Accident Reports (2)").ScrollArea = "A1:O229"
Sheets("Pick One Below").ScrollArea = "A1"
Sheets("Released Accident Reports (3)").ScrollArea = "A1:O400"
End Sub
 
Private Sub Workbook_Deactivate()
Application.ScreenUpdating = False
Application.ExecuteExcel4Macro "SHOW.TOOLBAR(""Ribbon"",True)"
Application.DisplayFormulaBar = True
Application.DisplayStatusBar = True
Application.ScreenUpdating = True
ActiveWindow.DisplayHorizontalScrollBar = True
ActiveWindow.DisplayWorkbookTabs = True
ActiveWindow.DisplayHeadings = True
Sheets("Released Accident Reports (2)").ScrollArea = ""
Sheets("Pick One Below").ScrollArea = ""
Sheets("Released Accident Reports (3)").ScrollArea = ""
End Sub
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
    Cancel = True
End Sub
 
Private Sub Workbook_BeforeClose(Cancel As Boolean)
    ThisWorkbook.Saved = True
End Sub
 
Private Sub Worksheet_Activate()
'On worksheet open turn off scroll bars.
 
 With ActiveWindow
 .DisplayHorizontalScrollBar = False
 .DisplayVerticalScrollBar = False
 End With
End Sub
 
Private Sub Worksheet_Deactivate()
'On worksheet open turn off scroll bars.
 
 With ActiveWindow
 .DisplayHorizontalScrollBar = True
 .DisplayVerticalScrollBar = True
 End With
End Sub
 
Last edited by a moderator:

Pullingmyhairout

New Member
Joined
Apr 7, 2016
Messages
29
I think his problem is this code:
Code:
Application.EnableCancelKey = xlDisabled
When he run a macro button (go to selected sheet), then the code above running and he has set the code in Workbook_Activate & Wokbook_Deactivate too. Just FYI (I am not expert about this) if eveyone here want help this man..hehe;)

NB: the Ribbon is disabled too, so the windows just show minimize, maximize and close button in right corner

I deleted that bit of code and still can't close it out
 

Forum statistics

Threads
1,136,445
Messages
5,675,900
Members
419,591
Latest member
mersanko

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top