FAQFAQ   SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log in/Register/PasswordLog in/Register/Password

Word and VB

 
   Mac (Home) -> Mac Word RSS
Related Topics:
How do I save a word doc as an ansi file in word 2003 - I have recently moved from word 2000 to 2003. I used to save files as ansi format to be able to import them into a DOS based database. Now I am at a loss for what to do. Is there any way to save word docs as text files with table kept?

word 2004 word count only shows total - In one document only of approx 100 000 words, the word count only shows the total. All other documents [some quite large] show the number of words on any given page. I need this feature. How do I get it working, please? [Have tried copying the whole..

Word PC documents to Word Mac X - I get a lot of emailed technical documents Most of them cause me no problems, but in some all or most of the Greek letters (betas, alphas, gammas and so on) do not display and are replaced by an Sometimes I can open these in..

Word X Mac - In Word X for Mac when a files is saved it saves as read only. I have been unable to find where to change this setting. Anyone able to give me a hand. It would be greatly These files are being saved on a hard drive and not a CD..

Word '04 crashing - I've had Office '04 for over a year now, and it's always been quite stable. But, today it's crashed 4 times. I don't know exactly what I was doing each time it crashed, but it's possible I was in the process of text. I don't think I've..
Next:  Mac Word: Word X for Mac  
Author Message
Steve Cronin

External


Since: Mar 10, 2006
Posts: 1



(Msg. 1) Posted: Fri Mar 10, 2006 12:59 am
Post subject: Word and VB
Archived from groups: microsoft>public>mac>office>word (more info?)

Folks;

I've poked around a bit and it seems there are some very helpful and
knowledgeable folks here!
Thanks to all of you who are of service!

OK so I'm trying to print using Word from AScript. I have 3 questions.

1) If I use the 'do Visual Basic' construct will that AppleScipt work
with Word v.X AND Word 2004?

2) What I want to do is essentially 'mail-merge' but the user is not
going to be placing merge tags.
They will simply put placeholders that I will substitute with data in
my script. They will be placing the text in normal layout, inside of
textboxes, and inside of tables. Could be some or all of the above.
How do I determine if there are any text boxes and then iterate over
them changing .Text 'abc' to 'xyz'?

3) I've scouted the past postings and I find some code snippets with
both straight AS and then a do VB with an open quote followed by long
paragraphs of VB code and a closing quote.
When I use this construct I always get a compiler error with the text
looking like ""& vbLf &" Dim cellText As String"& vbLf &" Dim i, j
As Integer"& vbLf &" With ActiveDocument.Tables( _
1)"& vbLf &" ...."
It looks like VB takes on a stray 'vbLf' from my ScriptEditor. What am
I doing wrong here?

Thanks for any help!
Steve
Back to top
Login to vote
Paul Berkowitz

External


Since: Jul 28, 2005
Posts: 196



(Msg. 2) Posted: Fri Mar 10, 2006 1:18 pm
Post subject: Re: Word and VB [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On 3/10/06 12:59 AM, in article
1141981197.046385.120190 RemoveThis @i40g2000cwc.googlegroups.com, "Steve Cronin"
<scronin RemoveThis @austin.rr.com> wrote:

> Folks;
>
> I've poked around a bit and it seems there are some very helpful and
> knowledgeable folks here!
> Thanks to all of you who are of service!
>
> OK so I'm trying to print using Word from AScript. I have 3 questions.
>
> 1) If I use the 'do Visual Basic' construct will that AppleScipt work
> with Word v.X AND Word 2004?

Yes, it will. 'do Visual Basic' continues to work in Word 2004 just like it
did in previous versions.
>
> 2) What I want to do is essentially 'mail-merge' but the user is not
> going to be placing merge tags.
> They will simply put placeholders that I will substitute with data in
> my script. They will be placing the text in normal layout, inside of
> textboxes, and inside of tables. Could be some or all of the above.
> How do I determine if there are any text boxes and then iterate over
> them changing .Text 'abc' to 'xyz'?

If you're planning to do this using 'do Visual Basic', why don't you ask in
the microsoft.public.word.vba.general newsgroup for the VBA code? They're
bug VBA experts there. Then just put it into a 'do Visual Basic' command
following the guidelines at http://word.mvps.org/mac/Applescript-VBA.html
>
> 3) I've scouted the past postings and I find some code snippets with
> both straight AS and then a do VB with an open quote followed by long
> paragraphs of VB code and a closing quote.
> When I use this construct I always get a compiler error with the text
> looking like ""& vbLf &" Dim cellText As String"& vbLf &" Dim i, j
> As Integer"& vbLf &" With ActiveDocument.Tables( _
> 1)"& vbLf &" ...."
> It looks like VB takes on a stray 'vbLf' from my ScriptEditor. What am
> I doing wrong here?
>

You're using Script Editor 2.x in OS X (10.3 or later). It's a Cocoa app, so
its line endings are all Unix linefeeds (LF) which VBA calls 'vbLf'. VBA
uses carriage returns (CR) which it knows as 'vbCr'. That webpage on VBA
and AppleScript should probably be updated to included that info. The
scripts you're looking at for models would have been made either with the
older carbon Script Editor or with (the expensive) Script Debugger which can
do CR line endings.

If you're not blessed with Script Debugger (which can be set to use "Mac CR"
endings, even in compiled scripts, after saving them first as Text), you
will have to run your script through a handler that replaces the LF line
endings with carriage returns. Do it this way:

set vbScript to "Type out your VB Code here
Within quotes, as text
Complete with normal line endings
etc.
etc.
etc.
"

set vbScript to my ConvertLineEndings(vbScript)

tell app "Microsoft Word"
do Visual Basic vbScript
end tell


to ConvertLineEndings(vbScript)
set scriptParas to paragraphs of vbScript
set AppleScript's text item delimiters to {return}
set vbScript to scriptParas as string
set AppleScript's text item delimiters to {""}
return vbScript
end ConvertLineEndings



---------------------

You could also use this subroutine to double up "" marks as needed, and so
on, thoughit gets a bit tricky (you need to escape those as \"\" -- see the
webpage.)


--
Paul Berkowitz
MVP MacOffice
Entourage FAQ Page: <http://www.entourage.mvps.org/faq/index.html>
AppleScripts for Entourage: <http://macscripter.net/scriptbuilders/>

Please "Reply To Newsgroup" to reply to this message. Emails will be
ignored.

PLEASE always state which version of Microsoft Office you are using -
**2004**, X or 2001. It's often impossible to answer your questions
otherwise.
Back to top
Login to vote
Display posts from previous:   
       Mac (Home) -> Mac Word All times are: Pacific Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum
Categories:
 Windows Forums
 Game Forums
 Linux Forums
  Mac Forums
 PDA Forums
 Mobile Forums
  Top  |  Store  |  RSS Feeds RSS  |  Data Feeds  |  Advertise  |  Submit  |  Bookmark  |  Newsletter  |  Contact