New code for Excel 2007 causes error in Excel 2000

derekpegg

Board Regular
Joined
Oct 7, 2005
Messages
145
Hi I have a workbook that I have designed in Excel 2000 which I am now trying to get working in 2007. I am slowly working through the things that are not working and changing the code accordingly.

One issue I had was that I needed to include the following line of code to make the workbook function correctly in 2007:

Code:
ThisWorkbook.CheckCompatibility = False

This works fine in 2007, but obviously Excel 2000 does not understand this as I think this is a new syntax in 2007.

I have a system in place which checks the version of Excel running and only attempts to run this line of code if it is running on 2007, but the macro still stops at this line in 2000.

I have tried a few other things with the final code being:

Code:
Sub Runif2007()

If Sheets("Report Creation").Range("C7") = "Excel 2007" Then

     On Error Resume Next
     Application.DisplayAlerts = False

     ThisWorkbook.checkcompatibility = False

     Application.DisplayAlerts = True
     
End If

End Sub

As I said previously, this should not even get to run on Excel 2000, but still brings up the error "Compile error: Method or data member not found".

Is there anyway around this issue as I guess it may come up again with new syntaxes that earlier versions of Excel do not understand?

Thanks for any help in advance.
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
I suspect that if you placed that particular line of code in its own separate sub routine and call the subroutine rather than the code line you won't get any error:

Code:
Sub Runif2007()

If Sheets("Report Creation").Range("C7") = "Excel 2007" Then

     On Error Resume Next
     Application.DisplayAlerts = False

     Call CheckCompatRoutine
     Application.DisplayAlerts = True
     
End If
 
Sub CheckCompatRoutine()
ThisWorkbook.CheckCompatibility = False
End Sub

You might like to look at the Application.Version property to determine what version of Excel the workbook has been opened in.

End Sub
 
Upvote 0
Big thanks Richard.

That seemed to do it.

Seems odd to a novice like me that that should make any difference, but it did so I won't try to understand the VBA logic of it all.

Thanks again

Derek


PS. On a global board with posts from all 4 corners, one Hampshire man can help another. Cheers!
 
Upvote 0

Forum statistics

Threads
1,214,832
Messages
6,121,849
Members
449,051
Latest member
excelquestion515

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