Well enough about me.

I have a multi-page form that I have created in Word, which is filled in
using VBA. As such this document has over 80 TextBoxes in it which are
populated by VBA code. Everything works great at home, but when I took the
document to work and opened it Word renumbered all of the TextBoxes in the
document. That is quite a problem since I have so many VBA references to the
TextBoxes.

Is there any way to ensure that the TextBox numbers will not get reassigned
when the document is opened on a different machine?

Re: I have a big problem by Jean-Guy

Jean-Guy
Tue Apr 17 07:51:13 CDT 2007

Patrick C. Simonds was telling us:
Patrick C. Simonds nous racontait que :

> Well enough about me.
>
> I have a multi-page form that I have created in Word, which is filled
> in using VBA. As such this document has over 80 TextBoxes in it which
> are populated by VBA code. Everything works great at home, but when I
> took the document to work and opened it Word renumbered all of the
> TextBoxes in the document. That is quite a problem since I have so
> many VBA references to the TextBoxes.
>
> Is there any way to ensure that the TextBox numbers will not get
> reassigned when the document is opened on a different machine?

What Word version?

In some cases, if you actually give them names of your own, chances are that
the names will not be changed, but there is no guarantee as I have heard of
people who had assigned their own names and Word still changed the names...

ActiveX controls are flaky in the Word environment.
I would advise not using them.

What is the context for the document usage? Who uses it and to what purpose?
Is it protected for forms?

--

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org



Re: I have a big problem by Patrick

Patrick
Tue Apr 17 09:21:55 CDT 2007

Version 2003. These are TextBoxes on the document it's self (I use VBA to
place text in the box). I know you can rename a TextBox that is used on
UserForm, but I am unaware how you would rename a TextBox you drew on a
document.


"Jean-Guy Marcil" <DontEvenTry@NoSpam> wrote in message
news:epWdt8OgHHA.3676@TK2MSFTNGP05.phx.gbl...
> Patrick C. Simonds was telling us:
> Patrick C. Simonds nous racontait que :
>
>> Well enough about me.
>>
>> I have a multi-page form that I have created in Word, which is filled
>> in using VBA. As such this document has over 80 TextBoxes in it which
>> are populated by VBA code. Everything works great at home, but when I
>> took the document to work and opened it Word renumbered all of the
>> TextBoxes in the document. That is quite a problem since I have so
>> many VBA references to the TextBoxes.
>>
>> Is there any way to ensure that the TextBox numbers will not get
>> reassigned when the document is opened on a different machine?
>
> What Word version?
>
> In some cases, if you actually give them names of your own, chances are
> that the names will not be changed, but there is no guarantee as I have
> heard of people who had assigned their own names and Word still changed
> the names...
>
> ActiveX controls are flaky in the Word environment.
> I would advise not using them.
>
> What is the context for the document usage? Who uses it and to what
> purpose? Is it protected for forms?
>
> --
>
> Salut!
> _______________________________________
> Jean-Guy Marcil - Word MVP
> jmarcilREMOVE@CAPSsympatico.caTHISTOO
> Word MVP site: http://www.word.mvps.org
>



Re: I have a big problem by Jean-Guy

Jean-Guy
Tue Apr 17 10:07:04 CDT 2007

Patrick C. Simonds was telling us:
Patrick C. Simonds nous racontait que :

> Version 2003. These are TextBoxes on the document it's self (I use
> VBA to place text in the box). I know you can rename a TextBox that
> is used on UserForm, but I am unaware how you would rename a TextBox
> you drew on a document.

Right click on it and select "Properties"

--

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org



Re: I have a big problem by Patrick

Patrick
Tue Apr 17 10:31:06 CDT 2007

When I do that, Properties is not an option. Reading between the lines of
all this great help I have been receiving, I think I have been creating my
TextBoxes the wrong way. I have been using Insert then TextBox and then
drawing my TextBox. I think what I should be doing is creating them by
selecting the Developer bar.


"Jean-Guy Marcil" <DontEvenTry@NoSpam> wrote in message
news:%23BhenIQgHHA.4388@TK2MSFTNGP03.phx.gbl...
> Patrick C. Simonds was telling us:
> Patrick C. Simonds nous racontait que :
>
>> Version 2003. These are TextBoxes on the document it's self (I use
>> VBA to place text in the box). I know you can rename a TextBox that
>> is used on UserForm, but I am unaware how you would rename a TextBox
>> you drew on a document.
>
> Right click on it and select "Properties"
>
> --
>
> Salut!
> _______________________________________
> Jean-Guy Marcil - Word MVP
> jmarcilREMOVE@CAPSsympatico.caTHISTOO
> Word MVP site: http://www.word.mvps.org
>



Re: I have a big problem by Jean-Guy

Jean-Guy
Tue Apr 17 10:54:09 CDT 2007

Patrick C. Simonds was telling us:
Patrick C. Simonds nous racontait que :

> When I do that, Properties is not an option. Reading between the
> lines of all this great help I have been receiving, I think I have
> been creating my TextBoxes the wrong way. I have been using Insert
> then TextBox and then drawing my TextBox. I think what I should be
> doing is creating them by selecting the Developer bar.
>


What Word version?

Because you wrote about numbered textboxes, I thought you were writing about
ActiveX controls that are inserted with the "Controls Toolbox" toolbar.

Now, finally, I understand what you are doing.

How were the textboxes numbered (I.e, how did you know which textbox was
represented by which number?) Are you referring the index number in the
shape collection?
Can I see the some of the code you used to fill the textboxes?

And again, in case there is an easier way to achieve your goal, what is the
context for the document usage? Who uses it and to what purpose?
Is it protected for forms?

--

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org



Re: I have a big problem by Patrick

Patrick
Tue Apr 17 11:11:39 CDT 2007

This a sample of the code I am using, where "Text Box 217" represents a
TextBox I drew on the document and "TextBox1" is the TextBox on the
UserForm. This document is used by a small group (2 to 3 people) to conduct
an eligibility interview over the phone. They wanted the ability to do the
interview sections randomly based on the conversation with the applicant. I
created UserForms for the various sections and on each UserForm there are
buttons which allow them to go to different parts of the interview. As the
exit (terminate) each UserForm the data is placed on the form. If the return
to any particular section to add or update data they can select the button
for that section, and when the UserForm opens it is populated with the data
currently on the form. It all works great here, but as I mentioned before,
when I took it to work, Word renumbered the TextBoxes on the document (not
the UserForms).


Private Sub UserForm_Terminate()

'Text Input''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

'Last Name
ActiveDocument.Shapes("Text Box 217").TextFrame.TextRange.Text =
TextBox1.Text

'First Name
ActiveDocument.Shapes("Text Box 218").TextFrame.TextRange.Text =
TextBox2.Text






"Jean-Guy Marcil" <DontEvenTry@NoSpam> wrote in message
news:u$8Z9iQgHHA.4868@TK2MSFTNGP06.phx.gbl...
> Patrick C. Simonds was telling us:
> Patrick C. Simonds nous racontait que :
>
>> When I do that, Properties is not an option. Reading between the
>> lines of all this great help I have been receiving, I think I have
>> been creating my TextBoxes the wrong way. I have been using Insert
>> then TextBox and then drawing my TextBox. I think what I should be
>> doing is creating them by selecting the Developer bar.
>>
>
>
> What Word version?
>
> Because you wrote about numbered textboxes, I thought you were writing
> about ActiveX controls that are inserted with the "Controls Toolbox"
> toolbar.
>
> Now, finally, I understand what you are doing.
>
> How were the textboxes numbered (I.e, how did you know which textbox was
> represented by which number?) Are you referring the index number in the
> shape collection?
> Can I see the some of the code you used to fill the textboxes?
>
> And again, in case there is an easier way to achieve your goal, what is
> the context for the document usage? Who uses it and to what purpose?
> Is it protected for forms?
>
> --
>
> Salut!
> _______________________________________
> Jean-Guy Marcil - Word MVP
> jmarcilREMOVE@CAPSsympatico.caTHISTOO
> Word MVP site: http://www.word.mvps.org
>



Re: I have a big problem by Jean-Guy

Jean-Guy
Tue Apr 17 12:09:50 CDT 2007

Patrick C. Simonds was telling us:
Patrick C. Simonds nous racontait que :

> This a sample of the code I am using, where "Text Box 217" represents
> a TextBox I drew on the document and "TextBox1" is the TextBox on the
> UserForm. This document is used by a small group (2 to 3 people) to
> conduct an eligibility interview over the phone. They wanted the
> ability to do the interview sections randomly based on the
> conversation with the applicant. I created UserForms for the various
> sections and on each UserForm there are buttons which allow them to
> go to different parts of the interview. As the exit (terminate) each
> UserForm the data is placed on the form. If the return to any
> particular section to add or update data they can select the button
> for that section, and when the UserForm opens it is populated with
> the data currently on the form. It all works great here, but as I
> mentioned before, when I took it to work, Word renumbered the
> TextBoxes on the document (not the UserForms).
>
> Private Sub UserForm_Terminate()
>
> 'Text Input''''''''''''''''''''''''''''''''''''''''''''''''''''''
> '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
>
> 'Last Name
> ActiveDocument.Shapes("Text Box 217").TextFrame.TextRange.Text =
> TextBox1.Text
>
> 'First Name
> ActiveDocument.Shapes("Text Box 218").TextFrame.TextRange.Text =
> TextBox2.Text
>

If you want to stick to your textbox approach, you can name those textboxes.
Insert a textbox any way you want to, then select it and run the following
code:

Selection.ShapeRange(1).Name = "MyTextboxName"

and then use "MyTextboxName" elsewhere in your code.

If the user can be trusted not to upset the document layout, or if it is
protected for forms, you can use DOCVARIABLE fields instead of textboxes.

Create the document variables like this:

ActiveDocument.Variables("FirstDocVar").Value = TextBox1.Text

and in the document, place a field:

{DOCVARIABLE FirstDocVar}

This way you do not have to interact directly with the document other than
doing a

ActiveDocument.Fields.Update

And loading the values is also easy:

TextBox1.Text = ActiveDocument.Variables("FirstDocVar").Value

--

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org