Re: do visual basic
Re: do visual basic
- Subject: Re: do visual basic
- From: Paul Berkowitz <email@hidden>
- Date: Wed, 10 Mar 2004 17:58:40 -0800
On 3/10/04 4:52 PM, "Jay Young" <email@hidden> wrote:
>
Another possibility could be to copy it to the clipboard and then have
>
AS pull the text from there:
>
>
----------
>
tell application "Microsoft Word"
>
do Visual Basic "Set dObj = New DataObject" & return & "x = 10" &
>
return & "dObj.SetText x" & return & "dObj.PutInClipboard"
>
end tell
>
>
set vbText to the clipboard
>
>
display dialog vbText
>
----------
That's good. It used to be (OS 9?) that Word used a different clipboard.
>
>
Careful of the email wrapping above. The 'do Visual Basic' line of
>
code between the 'tell' and 'end tell' is 1 line of code.
>
>
For some reason I could only get it to work when I added '& return &'
>
between each line of vba code. If I did this:
>
>
----------
>
tell application "Microsoft Word"
>
do Visual Basic "Set dObj = New DataObject
>
x = 10
>
dObj.SetText x
>
dObj.PutInClipboard"
>
end tell
>
----------
>
>
then it would make just 1 line of code in vba which of course would
>
break the script. I tested this in OS 10.3.2 with Word X.
That would be because you're using Script Editor 2.0, I think. SE 2.0 has
Unix linefeeds (ASCII character 10) as line endings. It understands scripts
made in other editors with CR (ASCII 13) between lines of code, and vice
versa. But inside literal strings, such as a 'do Visual basic' command, the
line endings will be LF, which VB will not see as line ends : VB requires
straight CR line endings. If you made your script in Smile or Script
Debugger using "Macintosh" line endings, it would work with the separate
lines. If you have a very long string to be used as a 'do Visual Basic', you
could write it out in the usual way, then get 'paragraphs' of it, and use
text item delimiters of (return) to convert it back to string. You generally
have to do the same thing replacing internal \" quotes with doubled \"\" so
you can do it sequentially.
--
Paul Berkowitz
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.