Re: Q: Passing values to VBA macros (Word 98)
Re: Q: Passing values to VBA macros (Word 98)
- Subject: Re: Q: Passing values to VBA macros (Word 98)
- From: "Bryan" <email@hidden>
- Date: Wed, 14 Feb 2001 15:11:13 -0500
There are several (untried) possibilities that come to mind.
The first is that VB macros are not apps so that you cannot tell them
directly, but you may be able to use a double tell, I don't know if MS Word
supports that though. Knowing MS, probably not.
something like:
tell application "Word"
do script "Passer"
tell script "Passer"
set varable thetext to "Applescript did this call"
end tell
end tell
The second possibility is to use the clipboard for AS to write to,
and read from in VB. Kind of a kludge, but very likely to be
successful.
Something like:
tell application "Word"
set the clipboard to "Applescript did this call"
do script "Passer()"
end tell
Then have the VBA read the clipboard as it's first step.
The third possibility is to try using the MS Word command:
"do Visual Basic"
tell application "Word"
do Visual Basic "Passer(\"Applescript did this call\")"
end tell
The fourth possibility (if all else fails) is to go back to
the "school of bigger hammer."
tell application "Word"
set the clipboard to (textOfPasser as text) & "Applescript did this
call" & (restOfTextOfPasser as text)
do script contents of clipboard
--or do Visual Basic contents of clipboard
end tell
Bryan Kaufman
----------
>
From: email@hidden (Frank Watzl)
>
To: AS users list <email@hidden>
>
Subject: Q: Passing values to VBA macros (Word 98)
>
Date: Now Wed, Feb 14, 2001, 02:47 PM
>
>
Hi, I have tried to figure this one out for three days now. I really hope
>
that somebody can help me, please.
>
>
In a Word 98 Document, which is currently open in Word's frontmost window,
>
there are three VBA subroutines:
>
>
Sub runner()
>
MsgBox "keep on running"
>
End Sub
>
>
Sub Passer(theParam)
>
MsgBox theParam
>
End Sub
>
>
Sub caller()
>
Call Passer("Caller did this call")
>
End Sub
>
>
From AS, I can
>
>
--+++++
>
tell application "Word"
>
do script "runner()"
>
end tell
>
--+++++
>
>
Runner's msgBox is displayed properly. Now, I want to pass a string to the
>
VBA subroutine named "Passer(theParam)". This doesn't work :-(
>
>
tell application "Word"
>
do script "Passer(\"Applescript did this call\")"
>
end tell
>
>
What I get is a VBA Code window opening, displaying
>
>
Sub TmpDDE()
>
>
Passer__ ("Applescript did this")
>
End Sub
>
>
accompanies by a dialog saying "Sub or Function not defined".
>
>
How can I successfully pass Parameters to a VBA sub?
>
>
>
>
Thanks,
>
Frank Watzl
>
_______________________________________________
>
applescript-users mailing list
>
email@hidden
>
http://www.lists.apple.com/mailman/listinfo/applescript-users