Go Back   The macosxhints Forums > OS X Help Requests > Applications



Reply
 
Thread Tools Rate Thread Display Modes
Old 10-19-2004, 06:16 PM   #1
mansky99
Prospect
 
Join Date: Oct 2004
Posts: 11
Jaguar Visual Basic "Shell" command on OSX 10.2.8

I'm trying to write some Visual Basic scripts to use w/Excel 10.1.5 on OSX 10.2.8 on a PB G4.
Specifically, I'm trying to bring up MS Word via a call to Shell in VB from an open Excel workbook.
This brings up Word : Shell(MacID("MSWD"), vbNormalFocus)
with a blank document just fine.

Trouble is I don't seem to be able to append a filename using MacID.
I want to bring up Word with a specific (existing) document w/o using MacID.
What I thought would be equivalent (according to the VB help) :

WordID = Shell(WordPath, vbNormalFocus) 'gets a handle
AppActivate WordID 'opens the handle

where WordPath is a Variant:
WordPath = "Macintosh HD:Applications:Microsoft Office X:Microsoft Word"

that points to the Word executable.

The call to Shell via a Variant simply gives an WordID = 0 indicating VBA wasn't able to create a process.

I really want to be able to call and return data from MySql via Perl scripts, so not being able to call Word from Excel via VB is pretty frustrating.

Any ideas would be greatly appreciated!

Thanks.
mansky99 is offline   Reply With Quote
Old 10-19-2004, 06:39 PM   #2
hayne
Site Admin
 
Join Date: Jan 2002
Location: Montreal
Posts: 32,473
Is it possible that WordPath is supposed to be a Unix path
(e.g. "/Applications/Microsoft Office X/Microsoft Word") instead of an OS9-style path?

But an alternative scheme that wouldn't require any VBA would be to use AppleScript to extract the info from Excel and then feed it into Word, etc. You can call AppleScript from Perl as illustrated in this other thread:
http://forums.macosxhints.com/showpo...7&postcount=10

Last edited by hayne; 10-19-2004 at 06:44 PM.
hayne is offline   Reply With Quote
Old 10-20-2004, 02:34 PM   #3
mansky99
Prospect
 
Join Date: Oct 2004
Posts: 11
Jaguar system vs osascript in Perl

The VB help files on OSX (MS Office 10.1.5) mention explicitly to use : instead of / as the delimiter on the Mac. I've tried both with the same result:
WordID is returned with a value of 0 (zero).

Thanks for the Perl script tip on the command /usr/bin/osascript, that's a command I haven't used before. (lots of Perl scripting on HP-UX and Solaris,
but only now getting around to the Mac).

Question: What's the difference between calling "system" in Perl and invoking /usr/bin/osascript ? Will "system" not work for calling Apple Scripts ?

Will osascript allow me to return to Perl arbitrary data structures such as hashes, or arrays of hashes. Or can I only return integers via osascript ?
mansky99 is offline   Reply With Quote
Old 10-20-2004, 04:25 PM   #4
hayne
Site Admin
 
Join Date: Jan 2002
Location: Montreal
Posts: 32,473
Quote:
Originally Posted by mansky99
Question: What's the difference between calling "system" in Perl and invoking /usr/bin/osascript ? Will "system" not work for calling Apple Scripts ?

Will osascript allow me to return to Perl arbitrary data structures such as hashes, or arrays of hashes. Or can I only return integers via osascript ?

Applescript's need to be compiled before they can be run - hence the need for 'osascript'.

AppleScript will allow you to return text to your Perl script from whence you can parse it to extract what you want.
hayne is offline   Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



All times are GMT -5. The time now is 01:55 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.