I would like to get fractional timer resolution in an Excel VBA project that has to be compatible with Windows Excel 2007 and Mac OS Excel 2011. Ive found a method in windows utilizing sleep
from kernel32.dll
and a method on Mac OS using MacScript("GetMilliSec")
.
I currently have limited access to a Mac, so I am not able to test this out directly right now. If I declare Sleep
like this:
Private Declare Sub Sleep Lib "kernel32.dll" (ByVal dwMilliseconds As Long)
Will an error be raised when the file is opened in a Mac? Or will the error be flagged only when/if Sleep
is called in a Mac?
I believe you'll need to use conditional compilation to avoid your API declaration causing an error on a Mac.
#If Mac Then
MsgBox "I'm a Mac"
#Else
MsgBox "I'm a PC"
#End If