|
|
#1 |
|
Prospect
Join Date: Oct 2004
Posts: 11
|
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. |
|
|
|
|
|
#2 |
|
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. |
|
|
|
|
|
#3 |
|
Prospect
Join Date: Oct 2004
Posts: 11
|
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 ? |
|
|
|
|
|
#4 | |||||||||||||||||||||||
|
Site Admin
Join Date: Jan 2002
Location: Montreal
Posts: 32,473
|
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. |
|||||||||||||||||||||||
|
|
|
![]() |
|
|