Several Errors/Dysfunctions in VB-Macros for Excel X

  • Thread starter Dr. Müschenborn
  • Start date
D

Dr. Müschenborn

I am relativly new to Mac OS X and have to port an existing
VB-Macro from Excel 97/2000 to Excel X Patch 1.5 on Mac OS X.2.6 or
later.
During the Port I found a couple of missing and/or errorous
functions:

1. FileSystemObject is not implemented.
2. Timer Object is not implemented.
3. Extended System Controls are not implemented.

4. The file listing of a directory does not work:

x = Dir("*.*")
Do While x <> ""
Debug.Print x
x = Dir
Loop

returns after the first call "x = Dir("*.*")" with a Null-String and
the following
loop ist not executed, although the directory was definitely not
empty.
The same result was obtained with "x = Dir("*")".
There was no error message.

5. The writing of data into an file opend for output does not work:

Open "FileName" For Output As #1
Print #1, "Hello World!"
Print #1, "Hello World!"
Close #1

creates the file "FileName", but the file remains empty.
There is no error message.

6. The call of an existing external executable doe not work:

Shell ("ExeName") or
Shell ("ExeName", Modus)

just returns with 0 PID. The executable "ExeName" is neither called
nor executed.
There is no error message, even if "ExeName" is contained in the
current working directory.

7. The call of C-functions in external C-Libraries does not work.
The Standard-C-Library libc.dylib was copied under the names
c, libc.a und libc.dylib into the directory
"/HarddiskName/Library/CFMSupport"
and it was tried to call the standard C-function "strlen" from VB:

Private Declare Function Strlen Lib "c" (ByVal Name) As Integer
Private Declare Function Strlen Lib "libc.a" (ByVal Name) As Integer
Private Declare Function Strlen Lib "libc.dylib" (ByVal Name) As
Integer
Private Declare Function Strlen Lib
"/HarddiskName/Library/CFMSupport/c" (ByVal Name) As Integer
Private Declare Function Strlen Lib
"/HarddiskName/Library/CFMSupport/libc.a" (ByVal Name) As Integer
Private Declare Function Strlen Lib
"/HarddiskName/Library/CFMSupport/libc.dylib" (ByVal Name) As Integer

In each case Runtime error 53 resulted: File (c, libc.a, libc.dylib,
....) not found.
The same result was obtained using a custom dynamic C-Library build
with gcc and libtool.

Can anybody help with (some of) these errors.
There might be just a simple security setting of which I am not avare.
Since there is apparently no documentation available, I am trying this
way.
 
J

J.E. McGimpsey

I am relativly new to Mac OS X and have to port an existing
VB-Macro from Excel 97/2000 to Excel X Patch 1.5 on Mac OS X.2.6 or
later.
During the Port I found a couple of missing and/or errorous
functions:

1. FileSystemObject is not implemented.

True. FileSystemObjects are part of the MicrosoftVisual
BasicScripting Edition (VBScript), a proprietary Windows technology.
Scripting the operating system on Macs is done via Applescript,
which MacOffice implements via the MacScript method.
2. Timer Object is not implemented.

True. The Timer Object is an ActiveX Control. ActiveX is also
proprietary to Windows. Several Applescript methods allow sub-second
timing, though without as fine a control as Timer.
3. Extended System Controls are not implemented.

See 2.
4. The file listing of a directory does not work:

x = Dir("*.*")
Do While x <> ""
Debug.Print x
x = Dir
Loop

returns after the first call "x = Dir("*.*")" with a Null-String and
the following
loop ist not executed, although the directory was definitely not
empty.
The same result was obtained with "x = Dir("*")".
There was no error message.

See Dir() in XL/VBA Help. DIR() on the Mac does not support
wildcards ("*.*" is a valid filename in MacOS). Instead, MacID is
implemented (not quite the same, but it can be useful).
5. The writing of data into an file opend for output does not work:

Open "FileName" For Output As #1
Print #1, "Hello World!"
Print #1, "Hello World!"
Close #1

creates the file "FileName", but the file remains empty.
There is no error message.

I can't reproduce this - I get a two-line text file named "FileName"
in the CurDir.
6. The call of an existing external executable doe not work:

Shell ("ExeName") or
Shell ("ExeName", Modus)

just returns with 0 PID. The executable "ExeName" is neither called
nor executed.
There is no error message, even if "ExeName" is contained in the
current working directory.

An easier way to call Shell is using MacID. See VBA Help. Also
Applescript can run external applications. You can even use
Applescript to call the Unix shell command.
7. The call of C-functions in external C-Libraries does not work.
The Standard-C-Library libc.dylib was copied under the names
c, libc.a und libc.dylib into the directory
"/HarddiskName/Library/CFMSupport"
and it was tried to call the standard C-function "strlen" from VB:

Private Declare Function Strlen Lib "c" (ByVal Name) As Integer
Private Declare Function Strlen Lib "libc.a" (ByVal Name) As Integer
Private Declare Function Strlen Lib "libc.dylib" (ByVal Name) As
Integer
Private Declare Function Strlen Lib
"/HarddiskName/Library/CFMSupport/c" (ByVal Name) As Integer
Private Declare Function Strlen Lib
"/HarddiskName/Library/CFMSupport/libc.a" (ByVal Name) As Integer
Private Declare Function Strlen Lib
"/HarddiskName/Library/CFMSupport/libc.dylib" (ByVal Name) As Integer

In each case Runtime error 53 resulted: File (c, libc.a, libc.dylib,
...) not found.
The same result was obtained using a custom dynamic C-Library build
with gcc and libtool.

I'll have to research this a bit more - I've used the carbonlib
external library, so I know it can be done, but I'll have to pull
out some of my old code.
 

Ask a Question

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.

Ask a Question

Top