document variable and paragraph return

D

Diane

Group,
Is there any way to program a paragraph return within a word document, not
using VBA, but using an "IF" statement within a document variable?? Example,
I have many document variables built into many MS Word documents, I have now
ran across a situation that I need to test a document variable, and then if
true, add some text. Before the text is added, I need a paragraph return,
ex: [if [DOCVARIABLE hst] = "Y" .......now I need to add a paragraph return,
and then text, this needs to be included with the document variable
condition. ]
Can this be done??
 
G

Graham Mayor

If you mean can you add to a document variable from a conditional field in
the document, the answer must be no. Fields read variable not write to them.
You can however insert a conditional field to include a paragraph mark and
the text ie

{ IF { DOCVARIABLE hst \*Upper} = "Y" "¶
Enter this text"}

pressing enter in place of ¶

Given that you have the field in the document what would be the benefit of
adding the content to the variable? The field would surely do the same job?

I am not convinced that you can include a conditional field within a
document variable in any case. You could however read and conditionally
rewrite variables using the vba you have ruled out.


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
D

Diane

Graham,
It worked!! That is exactly what I needed - Thank You!!
When I insert document variables, I use the default, *\Mergeformat, I
noticed your example indicated *\Upper, I'm not clear on the difference.
I'll research the difference, although, if you have some helpful notes on
this, that would be great!

Thanks for your interest in this post.
Diane

Graham Mayor said:
If you mean can you add to a document variable from a conditional field in
the document, the answer must be no. Fields read variable not write to them.
You can however insert a conditional field to include a paragraph mark and
the text ie

{ IF { DOCVARIABLE hst \*Upper} = "Y" "¶
Enter this text"}

pressing enter in place of ¶

Given that you have the field in the document what would be the benefit of
adding the content to the variable? The field would surely do the same job?

I am not convinced that you can include a conditional field within a
document variable in any case. You could however read and conditionally
rewrite variables using the vba you have ruled out.


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

Group,
Is there any way to program a paragraph return within a word
document, not using VBA, but using an "IF" statement within a
document variable?? Example, I have many document variables built
into many MS Word documents, I have now ran across a situation that I
need to test a document variable, and then if true, add some text.
Before the text is added, I need a paragraph return, ex: [if
[DOCVARIABLE hst] = "Y" .......now I need to add a paragraph return,
and then text, this needs to be included with the document variable
condition. ]
Can this be done??
 
G

Graham Mayor

In most cases the default mergeformat switch is not required. You can turn
it off http://www.gmayor.com/word_vba_examples.htm
The Upper switch is simply a reflection that the conditional fields are case
sensitive. Using upper allows you to enter y or Y. If you always use one or
the other then it can be left out and the correct test inserted in the
field. See http://www.gmayor.com/formatting_word_fields.htm

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

Graham,
It worked!! That is exactly what I needed - Thank You!!
When I insert document variables, I use the default, *\Mergeformat, I
noticed your example indicated *\Upper, I'm not clear on the
difference. I'll research the difference, although, if you have some
helpful notes on this, that would be great!

Thanks for your interest in this post.
Diane

Graham Mayor said:
If you mean can you add to a document variable from a conditional
field in the document, the answer must be no. Fields read variable
not write to them. You can however insert a conditional field to
include a paragraph mark and the text ie

{ IF { DOCVARIABLE hst \*Upper} = "Y" "¶
Enter this text"}

pressing enter in place of ¶

Given that you have the field in the document what would be the
benefit of adding the content to the variable? The field would
surely do the same job?

I am not convinced that you can include a conditional field within a
document variable in any case. You could however read and
conditionally rewrite variables using the vba you have ruled out.


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

Group,
Is there any way to program a paragraph return within a word
document, not using VBA, but using an "IF" statement within a
document variable?? Example, I have many document variables built
into many MS Word documents, I have now ran across a situation that
I need to test a document variable, and then if true, add some text.
Before the text is added, I need a paragraph return, ex: [if
[DOCVARIABLE hst] = "Y" .......now I need to add a paragraph return,
and then text, this needs to be included with the document variable
condition. ]
Can this be done??
 
D

Diane

Graham,
Thank you for those links - great examples!
I will be teaching someone some of the programming I've done with MS WORD,
your examples will be very helpful.
Thanks again,
Diane

Graham Mayor said:
In most cases the default mergeformat switch is not required. You can turn
it off http://www.gmayor.com/word_vba_examples.htm
The Upper switch is simply a reflection that the conditional fields are case
sensitive. Using upper allows you to enter y or Y. If you always use one or
the other then it can be left out and the correct test inserted in the
field. See http://www.gmayor.com/formatting_word_fields.htm

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

Graham,
It worked!! That is exactly what I needed - Thank You!!
When I insert document variables, I use the default, *\Mergeformat, I
noticed your example indicated *\Upper, I'm not clear on the
difference. I'll research the difference, although, if you have some
helpful notes on this, that would be great!

Thanks for your interest in this post.
Diane

Graham Mayor said:
If you mean can you add to a document variable from a conditional
field in the document, the answer must be no. Fields read variable
not write to them. You can however insert a conditional field to
include a paragraph mark and the text ie

{ IF { DOCVARIABLE hst \*Upper} = "Y" "¶
Enter this text"}

pressing enter in place of ¶

Given that you have the field in the document what would be the
benefit of adding the content to the variable? The field would
surely do the same job?

I am not convinced that you can include a conditional field within a
document variable in any case. You could however read and
conditionally rewrite variables using the vba you have ruled out.


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>


Diane wrote:
Group,
Is there any way to program a paragraph return within a word
document, not using VBA, but using an "IF" statement within a
document variable?? Example, I have many document variables built
into many MS Word documents, I have now ran across a situation that
I need to test a document variable, and then if true, add some text.
Before the text is added, I need a paragraph return, ex: [if
[DOCVARIABLE hst] = "Y" .......now I need to add a paragraph return,
and then text, this needs to be included with the document variable
condition. ]
Can this be done??
 
G

Graham Mayor

You are welcome :)

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham,
Thank you for those links - great examples!
I will be teaching someone some of the programming I've done with MS
WORD, your examples will be very helpful.
Thanks again,
Diane

Graham Mayor said:
In most cases the default mergeformat switch is not required. You
can turn it off http://www.gmayor.com/word_vba_examples.htm
The Upper switch is simply a reflection that the conditional fields
are case sensitive. Using upper allows you to enter y or Y. If you
always use one or the other then it can be left out and the correct
test inserted in the field. See
http://www.gmayor.com/formatting_word_fields.htm

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

Graham,
It worked!! That is exactly what I needed - Thank You!!
When I insert document variables, I use the default, *\Mergeformat,
I noticed your example indicated *\Upper, I'm not clear on the
difference. I'll research the difference, although, if you have some
helpful notes on this, that would be great!

Thanks for your interest in this post.
Diane

:

If you mean can you add to a document variable from a conditional
field in the document, the answer must be no. Fields read variable
not write to them. You can however insert a conditional field to
include a paragraph mark and the text ie

{ IF { DOCVARIABLE hst \*Upper} = "Y" "¶
Enter this text"}

pressing enter in place of ¶

Given that you have the field in the document what would be the
benefit of adding the content to the variable? The field would
surely do the same job?

I am not convinced that you can include a conditional field within
a document variable in any case. You could however read and
conditionally rewrite variables using the vba you have ruled out.


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>


Diane wrote:
Group,
Is there any way to program a paragraph return within a word
document, not using VBA, but using an "IF" statement within a
document variable?? Example, I have many document variables built
into many MS Word documents, I have now ran across a situation
that I need to test a document variable, and then if true, add
some text. Before the text is added, I need a paragraph return,
ex: [if [DOCVARIABLE hst] = "Y" .......now I need to add a
paragraph return, and then text, this needs to be included with
the document variable condition. ]
Can this be done??
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top