B
Bob Greenblatt
Bob Greenblatt:
Place it in the "/Library/ScriptingAdditions/" Folder.
Thanks Bernard. Works fine. Nice little trick.
Bob Greenblatt:
Place it in the "/Library/ScriptingAdditions/" Folder.
Bob Greenblatt said:I don¹t know what the VB statement ³system² is. It¹s not in the object
browser. Perhaps it¹s an apple script object, not VB. In any case, what
Bernard was trying to explain is in VB, it¹s Application.operatingsystem.
This returns a string like²Macintosh (PowerPC) 10.38². So to determine the
platform look at the left 3 characters.
I know I'm jumping in late, but I wouldn't mess with Application.System
at all. Rather I'd use conditional compilation:
#If Mac Then .../... #Else .../... #End If
that way, only the relevant code is even compiled, much less executed.
On my cross-platform apps, I segregate the platform specific code into a
module like this - for instance, my Replace() method is stuck into a
conditionally compiled module
.../...
so that WinXL2000/2002/2003 uses the native VBA6 method, and MacXL uses
mine, but I don't have to use workarounds in the main code.
JE said:I know I'm jumping in late, but I wouldn't mess with Application.System
at all. Rather I'd use conditional compilation:
#If Mac Then
Bernard Rey said:This is of course right. But Laurent insisted that he didn't know much about
Macs. And it may be easier for him to keep with some minor ajustements rather
than writing a really optimized code for the Mac (if there is, as he didn't
give much information about what his code was doing, except that it needed to
know if the Shift key was depressed when clicking on a button).
Well, anyway, now he'll have the complete set of tools ;-)
Don't disagree with your premise at all, and you're probably right.
For me, conditional compilation is much easier to work with than
modifying code to evaluate and adjust for the platform at run-time.
Probably just the way I think...
Oh, there may be a few tricks left...<g>
Bob Greenblatt said:I guess it's just a matter of style.
I know I'm jumping in late, but I wouldn't mess with Application.System
at all. Rather I'd use conditional compilation:
#If Mac Then
Bob Greenblatt:
Place it in the "/Library/ScriptingAdditions/" Folder.
I know what's happening here: you've been testing with MS Word, where
OperationSystem *is* a Property of System. But this is not so in Excel (where
there is no System class at all. In an Excel macro, System.OperatingSystem
results in an immediate syntax error.
Paul Berkowitz said:When I read up on this earlier in the Help, it indicated that in order for
that line to make sense, you'd first have to hard code
Mac = 1 ' on Macs
or
Mac = 0 ' on Windows
in the module. I.e. 'Mac' isn't a built-in application property or anything
like that - you have to set it. (Presumably you'd Dim it as a Const?) Am I
understanding that correctly? I don't see it in your code, JE, which makes
me wonder. I didn't do this because I figured Laurent might not want to have
to hard-code each version separately for different users.
You can define your own compiler constants (which you then have to set,
either with the #Const directive, or using the Conditional Compilation
Arguments textbox in the General tab of the VBE's Tools/<project>
Properties dialog) but three are predefined (see "Compiler Constants" in
XL/VBA Help): Win16, Win32, Mac.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.