Excel Programming Basics?

C

chris.dufresne

Hi,

I have a VB program I've written on Windows that essentially starts
Excel, then creates various Worksheets and populates them with data,
does some cell formatting, etc. Keep in mind, this is not a Macro that
is launched from within Excel this is a standalone executable. I
recently bought a Mac and I'd like to do the same thing. I've done many
google searches and I've come up empty on the subject.

What I'm looking for is the Library or Framework I need to interact
with Excel through C or C++ or something similar. A small code snippet
illustrating its use, if available, would also be great. Thanks in
advance,

--Chris
 
B

Bernard Rey

(e-mail address removed) a écrit :
I have a VB program I've written on Windows that essentially starts
Excel, then creates various Worksheets and populates them with data,
does some cell formatting, etc. Keep in mind, this is not a Macro that
is launched from within Excel this is a standalone executable. I
recently bought a Mac and I'd like to do the same thing. I've done many
google searches and I've come up empty on the subject.

Try using AppleScript. It's a system wide programming language and you can
very easily write a script launching Excel and lots of other things.

See:
http://www.macscripter.net/
or:
http://www.apple.com/applescript/developers/

What I'm looking for is the Library or Framework I need to interact
with Excel through C or C++ or something similar. A small code snippet
illustrating its use, if available, would also be great. Thanks in
advance,

tell application "Microsoft Excel"
activate
select sheet ("Sheet1")
set value of range "A2" to "Hello!"
end tell

These lines, pasted in the "Script Edito" would do what you can expect...
 
J

Jim Gordon MVP

Hi,

Since you are already familiar with visual basic you might be somewhat
comfortable with Excel's built-in visual basic editor. (View > toolbars
Visual Basic > Visual Basic Editor).

The VB editor on the Mac supports VBA version 5. There's no Active-X and
just about anything that's new in VB version 6 is not supported. The Mac
VB editor is pretty bare-bones but it will get the job done. You might
find using the Object Editor and the VB help system will be quite useful.

You can create compiled code and save it as Excel add-ins. These add-ins
can be treated like executables or they can be put into the add-ins
folder and can launch automatically whenever Excel opens using
Tools>Add-ins>Add.

Once in the VB editor read these help topics:
* Strategies for Developing Cross-Platform Solutions
* Differences between Excel VBA for Windows and Excel VBA for the Macintosh

In addition to using Visual Basic to build applications you can use
AppleScript and REALBasic.

Here's a good resource for you to check out, too:
http://www.mcgimpsey.com/excel/index.html

-Jim
 
C

chris.dufresne

Thanks, for all your advice. However it seems from what you're saying
that the solution I'm looking for doesn't exist in the form I'm really
looking for it. The data I populate the worksheets with comes from a
database query, which I believe requires Active-X, so Excel's built in
VB editor is out. Also I was hoping I wouldn't have to purchase
anything additional so REALBasic is out. While Apple script would
probably work, I was just hoping I could write something that was a
little more portable.
 
P

Paul Berkowitz

Thanks, for all your advice. However it seems from what you're saying
that the solution I'm looking for doesn't exist in the form I'm really
looking for it. The data I populate the worksheets with comes from a
database query, which I believe requires Active-X, so Excel's built in
VB editor is out. Also I was hoping I wouldn't have to purchase
anything additional so REALBasic is out. While Apple script would
probably work, I was just hoping I could write something that was a
little more portable.

If AppleScript works, then so will VBA, which is perfectly portable. You
could develop 99% of it as a macro within Excel - probably best to an add-in
in the Office/Startup/Excel folder. Then all you need to do is create a
two-line standalone AppleScript application to launch Excel and call the
macro in the add-in, and another two-line VB standalone to do the same on
Windows. You could also provide a 4-line installer for each platform if you
like.

--
Paul Berkowitz
MVP MacOffice
Entourage FAQ Page: <http://www.entourage.mvps.org/faq/index.html>
AppleScripts for Entourage: <http://macscripter.net/scriptbuilders/>

Please "Reply To Newsgroup" to reply to this message. Emails will be
ignored.

PLEASE always state which version of Microsoft Office you are using -
**2004**, X or 2001. It's often impossible to answer your questions
otherwise.
 

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