Dual Code

S

Sandy

Given that some of my users might want to open my Workbook in 2003 or 2007
(or convert to a 2007 Workbook) is the following viable? and if so what code
do I have to attach within the asterisks, to identify the versions.

Private Sub Workbook_BeforeClose(Cancel As Boolean)

'other code

Application.DisplayFormulaBar=True

If **** application version is 95-2003 **** Then

With Application
.CommandBars("Worksheet Menu Bar").Enabled = True
.CommandBars("Standard").Visible = True
.CommandBars("Formatting").Visible = True
.CommandBars("Drawing").Visible = True
End With

ElseIf **** application version is 2007 **** Then

If Not ActiveWorkbook.Saved Then
If (MsgBox("Do you want to save your changes?", vbYesNo)) = 6 Then
ActiveWorkbook.Save
Else
ActiveWorkbook.Saved = True
End If
Application.ExecuteExcel4Macro "SHOW.TOOLBAR(""Ribbon"",True)"
Application.DisplayFormulaBar = True

End If

'other code

End Sub

Thanks
Sandy
 
R

Rick Rothstein \(MVP - VB\)

The key is the Application.Version, which returns a String value...

If CLng(Application.Version) < 12 Then
' Excel 2003 or earlier
Else
' Excel 2007 (or, for the future, above)
End If

Rick
 
S

Sandy

Excellent Rick - Thank you
Sandy

Rick Rothstein (MVP - VB) said:
The key is the Application.Version, which returns a String value...

If CLng(Application.Version) < 12 Then
' Excel 2003 or earlier
Else
' Excel 2007 (or, for the future, above)
End If

Rick
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top