Thread: Dual Code
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Rick Rothstein \(MVP - VB\)[_2189_] Rick Rothstein \(MVP - VB\)[_2189_] is offline
external usenet poster
 
Posts: 1
Default Dual Code

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


"Sandy" wrote in message
...
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