Cork,
> Hi Russ -
>
[quoted text clipped - 4 lines]
> .Fields.Update
> End With
Yes, that will work. Provided the document is opened with a template that
has the fields already setup or you use code elsewhere to set them up. If
there are no fields in the document, then using .Fields.Update is not doing
anything useful.
> That's how I usually load the variable and it seems to work fine for
> other docs. It's not working for this one, though.
Apparently those docs had the fields already set up in them, by way of a
Global template or attached template or other VBA code, like I suggested in
my last message.
> Thank you for your reply!
>
> cork

Signature
Russ
drsmN0SPAMikleAThotmailD0Tcom.INVALID
corky_guy@yahoo.com - 09 Jul 2007 23:32 GMT
Yeah, see, that's what I don't understand. Here's what's in my
document:
{ DOCVARIABLE result \* MERGEFORMAT }
I didn't type it in either. I used INSERT | FIELD | DOCVARIABLE.
Whenever I execute the code, I receive: Error! No document variable
supplied.
Very odd.
Could it have anything to do with the way I am storing the variable as
string?
Good thing I'm in the beginners forum, eh?
Russ - 09 Jul 2007 23:51 GMT
Corky,
> Yeah, see, that's what I don't understand. Here's what's in my
> document:
>
> { DOCVARIABLE result \* MERGEFORMAT }
{ DOCVARIABLE "result" \* MERGEFORMAT }
In my first message to you, the above line is what I said you should see in
your exposed field code.
The difference being the double quotation marks, of course. It wants the
docvariable name quoted. You are correctly storing the variable value as a
string.
> I didn't type it in either. I used INSERT | FIELD | DOCVARIABLE.
>
[quoted text clipped - 6 lines]
>
> Good thing I'm in the beginners forum, eh?

Signature
Russ
drsmN0SPAMikleAThotmailD0Tcom.INVALID
Russ - 10 Jul 2007 00:01 GMT
Corky,
FYI:
There are functions in VBA to change a string to a number or date, or vice
versa, if you need to. In VBA help search for:
Type Conversion Functions
I'm not saying that you need to, now. Just so you'll know.
> Corky,
>
[quoted text clipped - 19 lines]
>>
>> Good thing I'm in the beginners forum, eh?

Signature
Russ
drsmN0SPAMikleAThotmailD0Tcom.INVALID
corky_guy@yahoo.com - 10 Jul 2007 01:33 GMT
Thanks Russ.
I'm still stumped:
{ DOCVARIABLE result \* MERGEFORMAT } is exactly how the docvariable
is listed in my document.
The VBA code (as seen above) is trying to
populate: .Variables("result") = dog
What am I missing here?
corky_guy@yahoo.com - 10 Jul 2007 02:46 GMT
OK, I got it. I changed:
Select Case ListBox1
Case MAN
dog = "1.1.1.1"
Case FEM
dog = "2.2.2.2"
End Select
to
Select Case ListBox1
Case "MAN"
dog = "1.1.1.1"
Case "FEM"
dog = "2.2.2.2"
End Select
ugh -- thanks for all of the help, Russ!
Russ - 10 Jul 2007 04:54 GMT
Corky,
I guess I didn't look over your code that closely when you said the same
code worked in other documents. So I thought the difference was in the new
document fields or new document lack of fields. And I assumed your MAN and
FEM were variables declared as strings or numbers.
I'm glad you worked it out.
Two things that might help in the future for debug purposes.
1. In the (DECLARATIONS) part of your code of each macro project or userform
code you use, you should always put the line:
Option Explicit
That statement tells the debugger to warn you when you try to use a variable
that is not declared. The debugger would have warned you that no variables
MAN or FEM were declared; like for example:
Dim MAN as String
or
Dim MAN as Integer
etc.
2. Use Case Else to warn you if there are no matches and the Case statements
fall through to the end.
Case Else
MsgBox "No Match Found"
> OK, I got it. I changed:
>
[quoted text clipped - 15 lines]
>
> ugh -- thanks for all of the help, Russ!

Signature
Russ
drsmN0SPAMikleAThotmailD0Tcom.INVALID