Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / February 2006

Tip: Looking for answers? Try searching our database.

How do I use Word and  script to produce a document.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Sandy - 21 Feb 2006 16:26 GMT
I need to produce a dynamic document using word and conditional statements or
scripting. Any assistance is greatly appreciative.  
Doug Robbins - Word MVP - 21 Feb 2006 18:51 GMT
You will have to give more information than that to receive any useful
assistance.

Signature

Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

>I need to produce a dynamic document using word and conditional statements
>or
> scripting. Any assistance is greatly appreciative.
Sandy - 21 Feb 2006 22:42 GMT
Is it possible in word to add script!!!!!!!!!! I have not done this in
word!!!!!!!!!!

In word what is the syntax of a conditional if statement conditional on two
variables.

ie: if state = "fl' and contract = 'equity"

> You will have to give more information than that to receive any useful
> assistance.
>
> >I need to produce a dynamic document using word and conditional statements
> >or
> > scripting. Any assistance is greatly appreciative.
Tony Jollans - 21 Feb 2006 22:46 GMT
1. Yes. Press Alt+F11 to open the Visual Basic Editor.

2. Almost.  if state = "fl" and contract = "equity" THEN

--
Enjoy,
Tony

> Is it possible in word to add script!!!!!!!!!! I have not done this in
> word!!!!!!!!!!
[quoted text clipped - 18 lines]
> > >or
> > > scripting. Any assistance is greatly appreciative.
Sandy - 22 Feb 2006 15:19 GMT
Doug I need a general idea of how word and script work. I am already a
programmer. I have not done script thou. I just need to know if I pass two
variables from another application to a script word document will this work.
Or, do I need some kind of event to run. Based on this info I need to write a
case statement or if then else statement. I need to know how I could run the
script from word. I just need info on how to get started.

> You will have to give more information than that to receive any useful
> assistance.
>
> >I need to produce a dynamic document using word and conditional statements
> >or
> > scripting. Any assistance is greatly appreciative.
Tony Jollans - 22 Feb 2006 16:09 GMT
Word uses Visual Basic for Applications (VBA) - effectively a variant of VB
designed to run inside a parent application. From VBA you have access to the
Word object model and that allows the code to interact with documents (and
users and the environment). You can code VBA in the Visual Basic Editor
(VBE) accessible via Alt+F11 from Word.

Are you invoking Word from 'another application' (in which case, OK) or are
you wanting to communicate with an existing running instance of Word (not so
easy)?

--
Enjoy,
Tony

> Doug I need a general idea of how word and script work. I am already a
> programmer. I have not done script thou. I just need to know if I pass two
[quoted text clipped - 17 lines]
> > >or
> > > scripting. Any assistance is greatly appreciative.
Sandy - 22 Feb 2006 19:56 GMT
I am invoking word from another application.

Could you help in getting me started.

Purpose is to print dynamic titles for this document.

For ex: I will be given one variables 1) Contract Type
Based on the contract type print the required  titles

Example of Contract Type: Equity, Straight Conversion,  Upgrade Conversion.

------------------------------------------------------------
Titles:
Contract Type: Equity

Company
Join Us
Equity
-------------------------------------------------

Titles:
Contract Type: Upgrade Conversion

Company
Join Us
Upgrade Conversion

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

Titles:
Contract Type: Straight Conversion

Company
Join Us
Straight Conversion
-----------------------------------------------------------------

And also how do I launch the word document?????

> Word uses Visual Basic for Applications (VBA) - effectively a variant of VB
> designed to run inside a parent application. From VBA you have access to the
[quoted text clipped - 35 lines]
> > > >or
> > > > scripting. Any assistance is greatly appreciative.
Tony Jollans - 22 Feb 2006 20:49 GMT
You don't say what application or language you are using so it's difficult
for me to say how you should do it or whether you should do it in Word
(fired from your app) or direct from your app.

The basic idea is

Set WordAppPointer = CreateObject("Word.Application")
WordAppPointer.Documents.Open("name of document")
WordAppPointer.Run "NameOfMacroInWord", "ParameterToMacro"

Then in the Word Macro build up the document as you wish.

--
Enjoy,
Tony

> I am invoking word from another application.
>
[quoted text clipped - 74 lines]
> > > > >or
> > > > > scripting. Any assistance is greatly appreciative.
Sandy - 22 Feb 2006 23:59 GMT
What is the difference with what you wrote

Set WordAppPointer = CreateObject("Word.Application")
> WordAppPointer.Documents.Open("name of document")
> WordAppPointer.Run "NameOfMacroInWord", "ParameterToMacro

and with what I found on google


Set objWord = CreateObject("Word.Application")
Set objDoc = objWord.Documents.Open("U:\My Documents\CCSI\Contract
Document\Contract Template.doc")

> You don't say what application or language you are using so it's difficult
> for me to say how you should do it or whether you should do it in Word
[quoted text clipped - 100 lines]
> > > > > >or
> > > > > > scripting. Any assistance is greatly appreciative.
Ishai Sagi - 23 Feb 2006 00:50 GMT
his code opens a document and then runs a macro that is in the
document.
what you found only opens a document.

both are viable options to what you are attempting to do (open a
document and change it). you can also use
"WordAppPointer.Documents.add" to create a new document instead of
opening an existing one.

If you have office 2003 or above, I guess what you should consider is
creating an XML schema for your document, create a template based on
that schema, and using the code, creating a new document based on that
template, and populating the xml nodes with the information from your
application.

What do you say?

> What is the difference with what you wrote
>
[quoted text clipped - 112 lines]
> > > > > > >or
> > > > > > > scripting. Any assistance is greatly appreciative.
Doug Robbins - Word MVP - 22 Feb 2006 20:54 GMT
Sounds like a little bit of knowledge might be dangerous<g>

See the article "Getting To Grips With VBA Basics In 15 Minutes" at:

http://word.mvps.org/FAQs/MacrosVBA/VBABasicsIn15Mins.htm

Signature

Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

> Doug I need a general idea of how word and script work. I am already a
> programmer. I have not done script thou. I just need to know if I pass two
[quoted text clipped - 13 lines]
>> >or
>> > scripting. Any assistance is greatly appreciative.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.