Verify excel Version upon opening or closing

andrewb90

Well-known Member
Joined
Dec 16, 2009
Messages
1,077
Hello all,

Is there any way to add something to my opening or closing code that would check what version of excel is being used?
I have a number of features that won't work with Excel 2003 or below, and they are critical features, so I just don't want the workbook to be used in Excel that's older than 2007 (Sorry Clippy).

Is this doable in someway?
 
That should work .. I see no problems unless of course Macros or Events are disabled :)
 
Last edited:
Upvote 0

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
lol, That's why I have this in place...Just in case...

Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)

Dim sht As Object
Application.Run "module5.destructure" 'Removing workbook structure pass
Sheets("Welcome").Visible = True
Sheets("Welcome").Select
For Each sht In Sheets
If sht.Name <> "Welcome" Then
sht.Visible = xlSheetVeryHidden
End If
Next sht
Application.Run "module5.structure"
Application.DisplayFormulaBar = False
Application.ExecuteExcel4Macro "Show.ToolBar(""Ribbon"",False)"
Application.Run "Module1.unCommand"
ActiveWorkbook.Save
End Sub

With this, only one sheet is available and no others can be unhidden... So I don't think there's anyway to get around it. Unless anybody sees something...;)
 
Upvote 0
Why are you removing the formula bar and Ribbon before closing the workbook !? That will leave the main application window inadequate for other currently open workbooks .

Also, no need to select the sheet in order to work on it plus try fully qualifying your objects to avoid potential problems in case other workbooks happen to be the active ones when executing the code (Although this shouldn't be a problem in this particular scenario because the code resides in the ThisWorkbook module but it is always a good practice to fully qualify your objects)

Code:
Private Sub Workbook_BekforeClose()

Dim sht As [COLOR=#ff0000][B]Worksheet[/B][/COLOR]
Application.Run "module5.destructure" 'Removing workbook structure pass
[COLOR=#ff0000][B]Me[/B][/COLOR].Sheets("Welcome").Visible = True
[B][COLOR=#008000]'Sheets("Welcome").Select[/COLOR][/B]
For Each sht In [B][COLOR=#ff0000]Me[/COLOR][/B].Sheets
If sht.Name <> "Welcome" Then
sht.Visible = xlSheetVeryHidden
End If
Next sht
Application.Run "module5.structure"
Application.DisplayFormulaBar = False
Application.ExecuteExcel4Macro "Show.ToolBar(""Ribbon"",False)"
Application.Run "Module1.unCommand"
[B][COLOR=#008000]'ActiveWorkbook.Save[/COLOR][/B]
[COLOR=#ff0000][B]Me[/B][/COLOR].Save
End Sub
 
Upvote 0
I appreciate the advice. I tried having another workbook open when I closed my workbook, and I didn't see the main ribbon disappear, though. It didn't seem to cause any problems switching between one workbook in full screen with no ribbon, to the other with ribbon and normal view. The only thing that I did notice is that my disabled hotkeys were in effect on the other sheet.
Now if I opened another sheet while my file was open, that did appear in full screen/no ribbon.
So, i'm wondering if it's possible then to have my sheet check if another file is open? I found some code online that uses a specific file name, but maybe just a way to see if another file is open, and then just a popup telling the user to close other excel files...
 
Upvote 0
I'll post that question in a new thread since that's not really on my original question.
 
Upvote 0

Forum statistics

Threads
1,214,569
Messages
6,120,286
Members
448,953
Latest member
Dutchie_1

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
Back
Top