PDA

View Full Version : VBA on a MAC



MWE
07-19-2013, 03:01 PM
I recently ran several xls files on a MAC running Excel2011 (essentially xl2010 for a MAC) and found some strange differences:
if a vbaproject is password protected on the PC, you can not view it on the MAC. The password is rejected as incorrect.
One of the procedures I tested sequences down a tab doing different things depending on what it finds in Col 1. Menu_Number = MenuSheet.Cells(Row, 1).Value
Select Case Menu_Number
Case -1 ' end of useful data, cleanup and exit sub
GoTo CleanUp
Case 0 ' start of new menu
This procedure has run without error on several different computers running xl2000, xl2003, xl2007 and xl2010 over the last 10+ years. It fails on the MAC running xl2011. Is this possibly an example of the two systems (PC vs MAC) having slightly different "values" for "-1"

SamT
07-20-2013, 08:32 AM
-1 is a MAC Boolean False. Use Case Is = -1

mikerickson
07-21-2013, 03:20 AM
-1 is a MAC Boolean False. Use Case Is = -1
That is wrong. On a Mac, as on a PC, CLng(True) = -1 and CLng(False) = 0

The possible sources of error that I see in that code is if the cell contains the string "-1" rather than the number -1.

Or if the cell holds the logicals TRUE or FALSE and that is an attempt to test them.

SamT
07-21-2013, 08:29 AM
Then my memory is wrong, and I'm not going to search for the help file on it, because my solution is right. :)

MWE
07-24-2013, 10:35 AM
thanks for the suggestions. I modified the code to be more explicit, e.g., Case = -1 rather than Case -1. Turns out that the problem is even stranger than I thought. Either version of the code runs fine on the MAC as long as the project is not password protected. Further, if the code is password protected on a PC and then ported to a MAC, you can not view the project code because the MAC does not accept the password as valid.