If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Selecting Fields for Update
Using Word2000 on Windows 2000 Professional
I have set up a template for a form which uses a combination of text form fields and ASK fields. The AutoNew macro (code shown below) in the form asks users to respond to three ASK field prompts and then locks the form, which has a bunch of check box and text form fields for them to fill in. ***************************************** Sub AutoNew() ' ' AutoNew Macro ' Macro recorded 10/12/2004 by Steve to update ASK fields at document creation ' ' Selection.WholeStory Selection.Fields.Update ' Selection.HomeKey Unit:=wdStory ActiveDocument.Protect Password:="", NoReset:=False, Type:= _ wdAllowOnlyFormFields End Sub ***************************** I want users to have the option of editing the ASK fields again if they so desire, which requires unlocking the form. So, I added a macro which is buttonized on a custom toolbar, based on the AutoNew macro, to unlock the document, update the fields, reset the ref fields and relock the document. Note that the "NoReset" value in the second macro has been set to "True". ***************************** Sub ProtectUnprotect() ' ' ProtectUnprotect Macro ' ActiveDocument.Unprotect Selection.WholeStory Selection.Fields.Update Selection.HomeKey Unit:=wdStory ActiveDocument.Protect Password:="", NoReset:=True, Type:= _ wdAllowOnlyFormFields ActiveDocument.PrintPreview ActiveDocument.ClosePrintPreview End Sub ***************************** When this macro runs, any check boxes have been checked keep their values but if any form text fields have been filled in, they are reset to blank. How can I set it up so that the only things updated when I relock the form are the ASK fields, and all other field values remain as input by the user? Thanks. - Steve |
#2
|
|||
|
|||
Have you tried this page on the Word MVPs' website?
http://www.word.mvps.org/FAQs/Macros...lfResetOff.htm Steve Daigler wrote: Using Word2000 on Windows 2000 Professional I have set up a template for a form which uses a combination of text form fields and ASK fields. The AutoNew macro (code shown below) in the form asks users to respond to three ASK field prompts and then locks the form, which has a bunch of check box and text form fields for them to fill in. ***************************************** Sub AutoNew() ' ' AutoNew Macro ' Macro recorded 10/12/2004 by Steve to update ASK fields at document creation ' ' Selection.WholeStory Selection.Fields.Update ' Selection.HomeKey Unit:=wdStory ActiveDocument.Protect Password:="", NoReset:=False, Type:= _ wdAllowOnlyFormFields End Sub ***************************** I want users to have the option of editing the ASK fields again if they so desire, which requires unlocking the form. So, I added a macro which is buttonized on a custom toolbar, based on the AutoNew macro, to unlock the document, update the fields, reset the ref fields and relock the document. Note that the "NoReset" value in the second macro has been set to "True". ***************************** Sub ProtectUnprotect() ' ' ProtectUnprotect Macro ' ActiveDocument.Unprotect Selection.WholeStory Selection.Fields.Update Selection.HomeKey Unit:=wdStory ActiveDocument.Protect Password:="", NoReset:=True, Type:= _ wdAllowOnlyFormFields ActiveDocument.PrintPreview ActiveDocument.ClosePrintPreview End Sub ***************************** When this macro runs, any check boxes have been checked keep their values but if any form text fields have been filled in, they are reset to blank. How can I set it up so that the only things updated when I relock the form are the ASK fields, and all other field values remain as input by the user? Thanks. - Steve |
#3
|
|||
|
|||
Thanks, David. That page has many good things in it, and did show me that I
have the form locking part of my macro set up properly for not resetting the text fields. So, I now realize that the problem is in my "wholestory" selection (see code below) which apparently resets the form text fields as well as the ask fields. What syntax would I use in the macro to either only select ASK fields as part of my selection set, or only update ASK fields rather than all of the fields in a "wholestory" selection set? Thanks. - Steve "David Beamish" wrote in message ... Have you tried this page on the Word MVPs' website? http://www.word.mvps.org/FAQs/Macros...lfResetOff.htm Steve Daigler wrote: Using Word2000 on Windows 2000 Professional I have set up a template for a form which uses a combination of text form fields and ASK fields. The AutoNew macro (code shown below) in the form asks users to respond to three ASK field prompts and then locks the form, which has a bunch of check box and text form fields for them to fill in. ***************************************** Sub AutoNew() ' ' AutoNew Macro ' Macro recorded 10/12/2004 by Steve to update ASK fields at document creation ' ' Selection.WholeStory Selection.Fields.Update ' Selection.HomeKey Unit:=wdStory ActiveDocument.Protect Password:="", NoReset:=False, Type:= _ wdAllowOnlyFormFields End Sub ***************************** I want users to have the option of editing the ASK fields again if they so desire, which requires unlocking the form. So, I added a macro which is buttonized on a custom toolbar, based on the AutoNew macro, to unlock the document, update the fields, reset the ref fields and relock the document. Note that the "NoReset" value in the second macro has been set to "True". ***************************** Sub ProtectUnprotect() ' ' ProtectUnprotect Macro ' ActiveDocument.Unprotect Selection.WholeStory Selection.Fields.Update Selection.HomeKey Unit:=wdStory ActiveDocument.Protect Password:="", NoReset:=True, Type:= _ wdAllowOnlyFormFields ActiveDocument.PrintPreview ActiveDocument.ClosePrintPreview End Sub ***************************** When this macro runs, any check boxes have been checked keep their values but if any form text fields have been filled in, they are reset to blank. How can I set it up so that the only things updated when I relock the form are the ASK fields, and all other field values remain as input by the user? Thanks. - Steve |
#4
|
|||
|
|||
One approach would be to avoid using the selection object at all and
write code to pick out the relevant fields. The following seemed to work for me in Word 2002: Sub ProtectUnprotect() ' ' ProtectUnprotect Macro ' Dim oField As Field ActiveDocument.Unprotect For Each oField In ActiveDocument.Fields If oField.Type = wdFieldAsk Then oField.Update End If Next oField ActiveDocument.Protect Password:="", NoReset:=True, Type:= _ wdAllowOnlyFormFields ActiveDocument.PrintPreview ActiveDocument.ClosePrintPreview End Sub Steve Daigler wrote: Thanks, David. That page has many good things in it, and did show me that I have the form locking part of my macro set up properly for not resetting the text fields. So, I now realize that the problem is in my "wholestory" selection (see code below) which apparently resets the form text fields as well as the ask fields. What syntax would I use in the macro to either only select ASK fields as part of my selection set, or only update ASK fields rather than all of the fields in a "wholestory" selection set? Thanks. - Steve "David Beamish" wrote in message ... Have you tried this page on the Word MVPs' website? http://www.word.mvps.org/FAQs/Macros...lfResetOff.htm Steve Daigler wrote: Using Word2000 on Windows 2000 Professional I have set up a template for a form which uses a combination of text form fields and ASK fields. The AutoNew macro (code shown below) in the form asks users to respond to three ASK field prompts and then locks the form, which has a bunch of check box and text form fields for them to fill in. ***************************************** Sub AutoNew() ' ' AutoNew Macro ' Macro recorded 10/12/2004 by Steve to update ASK fields at document creation ' ' Selection.WholeStory Selection.Fields.Update ' Selection.HomeKey Unit:=wdStory ActiveDocument.Protect Password:="", NoReset:=False, Type:= _ wdAllowOnlyFormFields End Sub ***************************** I want users to have the option of editing the ASK fields again if they so desire, which requires unlocking the form. So, I added a macro which is buttonized on a custom toolbar, based on the AutoNew macro, to unlock the document, update the fields, reset the ref fields and relock the document. Note that the "NoReset" value in the second macro has been set to "True". ***************************** Sub ProtectUnprotect() ' ' ProtectUnprotect Macro ' ActiveDocument.Unprotect Selection.WholeStory Selection.Fields.Update Selection.HomeKey Unit:=wdStory ActiveDocument.Protect Password:="", NoReset:=True, Type:= _ wdAllowOnlyFormFields ActiveDocument.PrintPreview ActiveDocument.ClosePrintPreview End Sub ***************************** When this macro runs, any check boxes have been checked keep their values but if any form text fields have been filled in, they are reset to blank. How can I set it up so that the only things updated when I relock the form are the ASK fields, and all other field values remain as input by the user? Thanks. - Steve |
#5
|
|||
|
|||
David-
This does exactly what I want to do in my form. Many thanks. - Steve "David Beamish" wrote in message ... One approach would be to avoid using the selection object at all and write code to pick out the relevant fields. The following seemed to work for me in Word 2002: Sub ProtectUnprotect() ' ' ProtectUnprotect Macro ' Dim oField As Field ActiveDocument.Unprotect For Each oField In ActiveDocument.Fields If oField.Type = wdFieldAsk Then oField.Update End If Next oField ActiveDocument.Protect Password:="", NoReset:=True, Type:= _ wdAllowOnlyFormFields ActiveDocument.PrintPreview ActiveDocument.ClosePrintPreview End Sub |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
SELECTING ALL FIELDS FOR A UNION QUERY | jeanne | Running & Setting Up Queries | 2 | August 18th, 2006 04:29 PM |
Date form fields in Word 2003 | Andy | General Discussion | 1 | November 11th, 2004 11:06 AM |
Outlook Mapping Fields aren't saved | ericb | Contacts | 6 | September 4th, 2004 07:43 AM |
Optional Merge Fields | Pete Bennett | Mailmerge | 4 | August 25th, 2004 11:03 AM |
Mail Merge two fields that have multiple lines with new line control code | Eric Li | Mailmerge | 7 | May 25th, 2004 06:10 PM |