ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Dual Code (https://www.excelbanter.com/excel-programming/413215-dual-code.html)

Sandy

Dual Code
 
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



Rick Rothstein \(MVP - VB\)[_2189_]

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




Sandy

Dual Code
 
Excellent Rick - Thank you
Sandy

"Rick Rothstein (MVP - VB)" wrote in
message ...
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





All times are GMT +1. The time now is 10:08 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com