Hi Jezebel,
Generally speaking, you are right, but, did you read the sentence I wrote
preceding my code? It is just that Con did not even include code that would
let the compiler know, or at least guess, that "jsano" was a formfield. So,
as I said, I just wanted him/her to undertsand that you cannot assign
properties to an undeclared object/variable as he had done in:
>Private Sub Document_Open()
> If jsano = "" Then
He had not declared what "jsano" was in his code and on top of that he was
working with assumed properties (the Result property of the formfield
"jsano")...
Also, Con's purpose was not to replace the content of "jsano" with a
predefined content, but to check if "jsano" was empty, and if so, to insert
some text from a source document.
So, I wrote that code to show him/her how it works because he/she said
he/she was new to VBA.
Finally, while your example is shorter and less cludgy, I do not think
he/she still could use it as is, you would have to provide him/her with a
more complete example to take into account that he/she was using this code
in an If statement. See his/her original post.
Cheers!
_____________________________________
Jean-Guy Marcil
jmarcil@sympatico.ca
> > _______________________________________
> > Dim ff As FormField
[quoted text clipped - 13 lines]
> ActiveDocument.FormFields("jsano").Result = "test"
> on error goto 0
Jezebel - 31 Oct 2003 00:06 GMT
sheesh, no need to be so defensive. Your explanation was fine, and indeed
your code would work. ('Exit For' after finding the target would be an
improvement -- no point going on looking once it's found)
> Hi Jezebel,
>
[quoted text clipped - 44 lines]
> > ActiveDocument.FormFields("jsano").Result = "test"
> > on error goto 0
JGM - 31 Oct 2003 02:53 GMT
Hi there,
Not defensive, just wanted to explain for Con's benefit.
You are right about the Exit For... I always forget that one!
Have a good one!
--
_______________________________________
Jean-Guy Marcil
jmarcil@sympatico.ca
> sheesh, no need to be so defensive. Your explanation was fine, and indeed
> your code would work. ('Exit For' after finding the target would be an
[quoted text clipped - 51 lines]
> > > ActiveDocument.FormFields("jsano").Result = "test"
> > > on error goto 0
Con - 31 Oct 2003 20:25 GMT
thank you all for your assistance.
> sheesh, no need to be so defensive. Your explanation was fine, and indeed
> your code would work. ('Exit For' after finding the target would be an
[quoted text clipped - 51 lines]
> > > ActiveDocument.FormFields("jsano").Result = "test"
> > > on error goto 0