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 / October 2007

Tip: Looking for answers? Try searching our database.

DOCUMENT VARIABLES

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
JJ - 25 Oct 2007 10:15 GMT
OS - XP Prof SP2, Office 2003.
I have a VBA Userform with a text box where people type in the number
of parties to the
agreement. If they type "2" then it must prompt twice for the 1st
Party name and 1st Party ID or Registration Number and prompt again
for 2nd Party and 2nd Party ID or Registration Number. If they type
"3" then it must prompt three times and assign to all different
variables. Then I have a word template which I would like to program
saying {DOCVARIABLE 1stParty} to insert the 1st party name, then
{DOCVARIABLE 1stPartyRegNo} the word "and" {DOCVARIABLE 2ndParty} to
insert the 2nd party name, then {DOCVARIABLE 2ndPartyRegNo}. However
if you have 3 parties it must do {DOCVARIABLE 1stPartyRegNo} to hard
returns (blank spaces) {DOCVARIABLE 2ndParty} to insert the 2nd party
name, then {DOCVARIABLE 2ndPartyRegNo} then the word "and" and
{DOCVARIABLE 3rdParty} {DOCVARIABLE 3rdPartyRegNo}. I know how to do
the form but I have no clue as to how to program the document for it
to know when to use 2 parties or when to use 3 parties. I thought of
something like "if docvariable parties = 2 then docvariable 1st
Party,
docvariable 2nd party and docvariable 3rd party" but somehow I am not
managing to get the programming in the word template to understand my
commands. Unless I assign the whole toot to one variable and only
insert the one variable in my document. Any assistance or ideas will
be appreciated.
Doug Robbins - Word MVP - 26 Oct 2007 05:54 GMT
Assuming that you have a control named txtParties, then use the following
code

With ActiveDocument
   .Variables("FirstParty").Value = txtFirstParty
   .Variables("FirstPartyID").Value = txtFirstPartyID
   .Variables("SecondParty").Value = txtSecondParty
   .Variables("SecondPartyID").Value = txtSecondPartyID
   If txtParties = 3 then
       .Variables("ThirdParty").Value = vbCr & "and" & vbCr & txtThirdParty
       .Variables("FirstPartyID").Value = txtThirdPartyID
   End If
   .Range.Fields.Update
End With
   .
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

> OS - XP Prof SP2, Office 2003.
> I have a VBA Userform with a text box where people type in the number
[quoted text clipped - 20 lines]
> insert the one variable in my document. Any assistance or ideas will
> be appreciated.
JJ - 26 Oct 2007 09:33 GMT
On Oct 26, 6:54 am, "Doug Robbins - Word MVP"
<d...@REMOVECAPSmvps.org> wrote:
> Assuming that you have a control named txtParties, then use the following
> code
[quoted text clipped - 45 lines]
>
> - Show quoted text -

Doug thanx that's perfect but I already had that. The problem is how
do I stop having Errors in my word document as in the word document I
say {DOCVARIABLE Firstparty] {DOCVARIABLE SecondParty} which works
correct as those variables always exist. Then I have {DOCVARIABLE
Thirdparty} but if there are isn't a third party the DOCVARIABLES
gives an error in my document and it stays there. Therefore me asking
how do I programme the document to say if the variable exist place it
in the specific place in the document. If it doesn't exist, ignore it.
So if Docvariable thirdparty is "" ignore it. I hope you understand
what I am trying to say.
Doug Robbins - Word MVP - 26 Oct 2007 11:16 GMT
Before I posted that, I did a bit of research and came to the conclusion
that if you do not assign a value to the variable (which is not being done
because in the case of the ThirdParty variables, they are inside the
If...End If construction.

The alternative would be to create the whole shootin match as one variable.

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

> On Oct 26, 6:54 am, "Doug Robbins - Word MVP"
> <d...@REMOVECAPSmvps.org> wrote:
[quoted text clipped - 59 lines]
> So if Docvariable thirdparty is "" ignore it. I hope you understand
> what I am trying to say.
 
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.