• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: do visual basic
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: do visual basic


  • Subject: Re: do visual basic
  • From: Michael Grant <email@hidden>
  • Date: Wed, 10 Mar 2004 20:23:26 -0600

Do any of you folks happen to know offhand the VBA code to get a Word document's full wordcount?
Thanks,
Michael


On Mar 10, 2004, at 7:58 PM, Paul Berkowitz wrote:

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.



--
The Utah Jazz know where their butt is breaded.
- Quinn Buckner
_______________________________________________
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.


  • Follow-Ups:
    • Re: do visual basic
      • From: David wignall <email@hidden>
References: 
 >Re: do visual basic (From: Paul Berkowitz <email@hidden>)

  • Prev by Date: Re: do visual basic
  • Next by Date: Re: Basic: scripting OS X System Profiler
  • Previous by thread: Re: do visual basic
  • Next by thread: Re: do visual basic
  • Index(es):
    • Date
    • Thread