updating field forms using

Forum home » Delegate support and help forum » Microsoft Excel VBA Training and help » Updating field forms using VBA

Updating field forms using VBA

resolvedResolved · Urgent Priority · Version 2010

Edited on Tue 17 Feb 2015, 16:26

NAME-REMOVAL has attended:
Word Intermediate course
Word Advanced course
Excel VBA Introduction course
Excel VBA Intermediate course

Updating field forms using VBA

Hi,
I have 10 labels on one page in word, I would like to create a macro which will update all of them after filling with text the first field form. It will be changed every week what is the best solution for it?

It looks like that:

Network name: xxx
Username: yyy
Password: (this part must be automatically changed by macro)

I used thew following vba solution but it doesn't work:

Sub CopyField()
Dim Temp as String

Temp = ActiveDocument.FormFields("Text1").Result
ActiveDocument.FormFields("Text2").Result = Temp
End Sub

Thanks in advance.

RE: Updating field forms using VBA

Hi Bozena

Can I just clarify what type of form fields you are using? Your code works for me with the legacy type (Ab) of form control under the Developer tab, legacy Tools.

I added your macro to the (Run macro on) Exit property of the Text1 field.

Regards
Doug Dunn
Best STL

RE: Updating field forms using VBA

Hi Doug,

Thank you for your prompt reply.

My form fields are the legacy type (Ab) and I also added my macro to the (Run macro on) Exit property of the Text1 field.

When I run the macro I got the error: Run-time error '5941': The requested member of the collection does not exist.

Then when I click 'debug' it is highlighting this line:
Temp = ActiveDocument.FormFields("Text1").Result

Kind regards,
Bozena

RE: Updating field forms using VBA

Bozena

It might be easier if you send your works file.
When you click Reply choose Upload.

I can look at it today i fyou can.

Regards
Doug

RE: Updating field forms using VBA

Dough,

When I click reply there is no 'upload' option. Is there any other option to send you my work file?

Many thanks,
Bozena

RE: Updating field forms using VBA

Hi Dough,

Mystery solved :) It works, I just haven't restrict editing and when I enter something into form field I just delete it.

Thank you for your help.
Bozena

RE: Updating field forms using VBA

Great!
Yes you always have to restrict editing before updating form fields. Glad it's working now.

Doug

 

Training courses

 

Training information:

Welcome. Please choose your application (eg. Excel) and then post your question.

Our Microsoft Qualified trainers will then respond within 24 hours (working days).

Frequently Asked Questions
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.


 

Excel tip:

Change the Default Width of All Columns in Excel 2010

If you want to change the width of the columns in your Excel 2010 spreadsheet, making them either larger or smaller, here's how:

In the Cells group on the Home tab, click Format.

Hover over the section called Cell Size and a drop down list will appear, select Default Width from this list.

In the Standard Width dialog box, enter the size you want to set as the default width and click OK.

View all Excel hints and tips


Server loaded in 0.07 secs.