A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Word » Tables
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Clear Form Fields



 
 
Thread Tools Display Modes
  #1  
Old January 30th, 2009, 12:36 AM posted to microsoft.public.word.tables
Jamie
external usenet poster
 
Posts: 317
Default Clear Form Fields

I am working in Word 2003.

I have a table made up of 3 rows, the first two rows have 4 columns, the
last is one column. The table looks like this:

Row 1: Date: FormField Client Name: FormField
Row 2: Referred To: FormField Follow-Up Date:FormField
Row 3: Comments:
FormField

This is a template and when the user tabs out of the Comments FormField I
have an On Exit macro that copies the table including the FormFields. I can’t
come up with coding to clear the FormFields in the new rows. My coding for
copying and pasting the table is as follows:

CopyTable Macro

ActiveDocument.Unprotect

Selection.MoveUp Unit:=wdLine, Count:=3
Selection.MoveDown Unit:=wdLine, Count:=2, Extend:=wdExtend
Selection.Copy
Selection.MoveDown Unit:=wdLine, Count:=1
Selection.PasteAndFormat (wdTableOriginalFormatting)
Selection.MoveUp Unit:=wdLine, Count:=4

ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True

End Sub

Again this works as far as copying the table but I need the newly pasted
FormFields to be blank instead of having duplicate info from above. Any help
with this is greatly appreciated.
--
Jamie
  #2  
Old January 31st, 2009, 02:15 PM posted to microsoft.public.word.tables
Graham Mayor
external usenet poster
 
Posts: 18,297
Default Clear Form Fields

See the examples - Add a row to a table in a protected form and Repeat a
block of formatted text and form fields based upon the content of another
form field at http://www.gmayor.com/word_vba_examples.htm

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



Jamie wrote:
I am working in Word 2003.

I have a table made up of 3 rows, the first two rows have 4 columns,
the last is one column. The table looks like this:

Row 1: Date: FormField Client Name: FormField
Row 2: Referred To: FormField Follow-Up Date:FormField
Row 3: Comments:
FormField

This is a template and when the user tabs out of the Comments
FormField I have an On Exit macro that copies the table including the
FormFields. I can't come up with coding to clear the FormFields in
the new rows. My coding for copying and pasting the table is as
follows:

CopyTable Macro

ActiveDocument.Unprotect

Selection.MoveUp Unit:=wdLine, Count:=3
Selection.MoveDown Unit:=wdLine, Count:=2, Extend:=wdExtend
Selection.Copy
Selection.MoveDown Unit:=wdLine, Count:=1
Selection.PasteAndFormat (wdTableOriginalFormatting)
Selection.MoveUp Unit:=wdLine, Count:=4

ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True

End Sub

Again this works as far as copying the table but I need the newly
pasted FormFields to be blank instead of having duplicate info from
above. Any help with this is greatly appreciated.



  #3  
Old February 2nd, 2009, 07:19 PM posted to microsoft.public.word.tables
Jamie
external usenet poster
 
Posts: 317
Default Clear Form Fields

Thanks for your reply Graham. I’ve looked at your coding for Add a Row to a
Table in a Protected Form and I am still at a loss as to how to clear the
pasted formfields. The coding that I currently have, copies all the
information including the formfields, now I just need to clear the
formfields. My columns are not the same width and the last row is a merge of
all 4 columns. I’ve been pulling things out of your code to see if I can get
the formfields to clear, but unfortunately I don’t know enough to be
successful.

Thanks for your help.

--
Jamie


"Graham Mayor" wrote:

See the examples - Add a row to a table in a protected form and Repeat a
block of formatted text and form fields based upon the content of another
form field at http://www.gmayor.com/word_vba_examples.htm

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



Jamie wrote:
I am working in Word 2003.

I have a table made up of 3 rows, the first two rows have 4 columns,
the last is one column. The table looks like this:

Row 1: Date: FormField Client Name: FormField
Row 2: Referred To: FormField Follow-Up Date:FormField
Row 3: Comments:
FormField

This is a template and when the user tabs out of the Comments
FormField I have an On Exit macro that copies the table including the
FormFields. I can't come up with coding to clear the FormFields in
the new rows. My coding for copying and pasting the table is as
follows:

CopyTable Macro

ActiveDocument.Unprotect

Selection.MoveUp Unit:=wdLine, Count:=3
Selection.MoveDown Unit:=wdLine, Count:=2, Extend:=wdExtend
Selection.Copy
Selection.MoveDown Unit:=wdLine, Count:=1
Selection.PasteAndFormat (wdTableOriginalFormatting)
Selection.MoveUp Unit:=wdLine, Count:=4

ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True

End Sub

Again this works as far as copying the table but I need the newly
pasted FormFields to be blank instead of having duplicate info from
above. Any help with this is greatly appreciated.




  #4  
Old February 3rd, 2009, 07:15 AM posted to microsoft.public.word.tables
Graham Mayor
external usenet poster
 
Posts: 18,297
Default Clear Form Fields

Having inserted the fields, you need to set their values to nul

eg

ActiveDocument.FormFields("Bookmarkname").Result = ""#

However when copying and pasting the pasted row will not have bookmark
names, so you would need to define the copied range (here Table 1 row 2) and
zero all the fields in that range - eg along the lines of

Sub ResetFormFields()
Dim oRng As Range
Dim oFld As FormFields
Dim i As Long
Set oRng = ActiveDocument.Tables(1).Rows(2).Range
Set oFld = oRng.FormFields
For i = 1 To oFld.Count
oFld(i).Select
If oFld(i).Type = wdFieldFormDropDown Then
oFld(i).Result = oFld(i).DropDown.ListEntries(1).name
Else
oFld(i).Result = ""
End If
Next
End Sub


--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org




Jamie wrote:
Thanks for your reply Graham. I've looked at your coding for Add a
Row to a Table in a Protected Form and I am still at a loss as to how
to clear the pasted formfields. The coding that I currently have,
copies all the information including the formfields, now I just need
to clear the formfields. My columns are not the same width and the
last row is a merge of all 4 columns. I've been pulling things out of
your code to see if I can get the formfields to clear, but
unfortunately I don't know enough to be successful.

Thanks for your help.


See the examples - Add a row to a table in a protected form and
Repeat a block of formatted text and form fields based upon the
content of another form field at
http://www.gmayor.com/word_vba_examples.htm

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



Jamie wrote:
I am working in Word 2003.

I have a table made up of 3 rows, the first two rows have 4 columns,
the last is one column. The table looks like this:

Row 1: Date: FormField Client Name: FormField
Row 2: Referred To: FormField Follow-Up Date:FormField
Row 3: Comments:
FormField

This is a template and when the user tabs out of the Comments
FormField I have an On Exit macro that copies the table including
the FormFields. I can't come up with coding to clear the FormFields
in the new rows. My coding for copying and pasting the table is as
follows:

CopyTable Macro

ActiveDocument.Unprotect

Selection.MoveUp Unit:=wdLine, Count:=3
Selection.MoveDown Unit:=wdLine, Count:=2, Extend:=wdExtend
Selection.Copy
Selection.MoveDown Unit:=wdLine, Count:=1
Selection.PasteAndFormat (wdTableOriginalFormatting)
Selection.MoveUp Unit:=wdLine, Count:=4

ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True

End Sub

Again this works as far as copying the table but I need the newly
pasted FormFields to be blank instead of having duplicate info from
above. Any help with this is greatly appreciated.



  #5  
Old February 3rd, 2009, 07:42 AM posted to microsoft.public.word.tables
Graham Mayor
external usenet poster
 
Posts: 18,297
Default Clear Form Fields

Oops - I don't know where that # sneaked in from
It should have read
ActiveDocument.FormFields("Bookmarkname").Result = ""

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



Graham Mayor wrote:
Having inserted the fields, you need to set their values to nul

eg

ActiveDocument.FormFields("Bookmarkname").Result = ""#

However when copying and pasting the pasted row will not have bookmark
names, so you would need to define the copied range (here Table 1 row
2) and zero all the fields in that range - eg along the lines of

Sub ResetFormFields()
Dim oRng As Range
Dim oFld As FormFields
Dim i As Long
Set oRng = ActiveDocument.Tables(1).Rows(2).Range
Set oFld = oRng.FormFields
For i = 1 To oFld.Count
oFld(i).Select
If oFld(i).Type = wdFieldFormDropDown Then
oFld(i).Result = oFld(i).DropDown.ListEntries(1).name
Else
oFld(i).Result = ""
End If
Next
End Sub



Jamie wrote:
Thanks for your reply Graham. I've looked at your coding for Add a
Row to a Table in a Protected Form and I am still at a loss as to how
to clear the pasted formfields. The coding that I currently have,
copies all the information including the formfields, now I just need
to clear the formfields. My columns are not the same width and the
last row is a merge of all 4 columns. I've been pulling things out of
your code to see if I can get the formfields to clear, but
unfortunately I don't know enough to be successful.

Thanks for your help.


See the examples - Add a row to a table in a protected form and
Repeat a block of formatted text and form fields based upon the
content of another form field at
http://www.gmayor.com/word_vba_examples.htm

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



Jamie wrote:
I am working in Word 2003.

I have a table made up of 3 rows, the first two rows have 4
columns, the last is one column. The table looks like this:

Row 1: Date: FormField Client Name: FormField
Row 2: Referred To: FormField Follow-Up Date:FormField
Row 3: Comments:
FormField

This is a template and when the user tabs out of the Comments
FormField I have an On Exit macro that copies the table including
the FormFields. I can't come up with coding to clear the FormFields
in the new rows. My coding for copying and pasting the table is as
follows:

CopyTable Macro

ActiveDocument.Unprotect

Selection.MoveUp Unit:=wdLine, Count:=3
Selection.MoveDown Unit:=wdLine, Count:=2, Extend:=wdExtend
Selection.Copy
Selection.MoveDown Unit:=wdLine, Count:=1
Selection.PasteAndFormat (wdTableOriginalFormatting)
Selection.MoveUp Unit:=wdLine, Count:=4

ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True

End Sub

Again this works as far as copying the table but I need the newly
pasted FormFields to be blank instead of having duplicate info from
above. Any help with this is greatly appreciated.



  #6  
Old February 18th, 2009, 12:34 AM posted to microsoft.public.word.tables
Jamie
external usenet poster
 
Posts: 317
Default Clear Form Fields

Hi Graham, I've been trying to use your code, but cannot seem to get it to
work. I keep trying which has only resulted in me prolonging this new
posting to you as well as admitting that I am at a loss.

My only suggestion, if you are still willing to help, is to send my document
to you. Of course, you'll need to walk me through that as well as I have
never attached a file to a post.
--
Jamie


"Graham Mayor" wrote:

Oops - I don't know where that # sneaked in from
It should have read
ActiveDocument.FormFields("Bookmarkname").Result = ""

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



Graham Mayor wrote:
Having inserted the fields, you need to set their values to nul

eg

ActiveDocument.FormFields("Bookmarkname").Result = ""#

However when copying and pasting the pasted row will not have bookmark
names, so you would need to define the copied range (here Table 1 row
2) and zero all the fields in that range - eg along the lines of

Sub ResetFormFields()
Dim oRng As Range
Dim oFld As FormFields
Dim i As Long
Set oRng = ActiveDocument.Tables(1).Rows(2).Range
Set oFld = oRng.FormFields
For i = 1 To oFld.Count
oFld(i).Select
If oFld(i).Type = wdFieldFormDropDown Then
oFld(i).Result = oFld(i).DropDown.ListEntries(1).name
Else
oFld(i).Result = ""
End If
Next
End Sub



Jamie wrote:
Thanks for your reply Graham. I've looked at your coding for Add a
Row to a Table in a Protected Form and I am still at a loss as to how
to clear the pasted formfields. The coding that I currently have,
copies all the information including the formfields, now I just need
to clear the formfields. My columns are not the same width and the
last row is a merge of all 4 columns. I've been pulling things out of
your code to see if I can get the formfields to clear, but
unfortunately I don't know enough to be successful.

Thanks for your help.


See the examples - Add a row to a table in a protected form and
Repeat a block of formatted text and form fields based upon the
content of another form field at
http://www.gmayor.com/word_vba_examples.htm

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



Jamie wrote:
I am working in Word 2003.

I have a table made up of 3 rows, the first two rows have 4
columns, the last is one column. The table looks like this:

Row 1: Date: FormField Client Name: FormField
Row 2: Referred To: FormField Follow-Up Date:FormField
Row 3: Comments:
FormField

This is a template and when the user tabs out of the Comments
FormField I have an On Exit macro that copies the table including
the FormFields. I can't come up with coding to clear the FormFields
in the new rows. My coding for copying and pasting the table is as
follows:

CopyTable Macro

ActiveDocument.Unprotect

Selection.MoveUp Unit:=wdLine, Count:=3
Selection.MoveDown Unit:=wdLine, Count:=2, Extend:=wdExtend
Selection.Copy
Selection.MoveDown Unit:=wdLine, Count:=1
Selection.PasteAndFormat (wdTableOriginalFormatting)
Selection.MoveUp Unit:=wdLine, Count:=4

ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True

End Sub

Again this works as far as copying the table but I need the newly
pasted FormFields to be blank instead of having duplicate info from
above. Any help with this is greatly appreciated.




  #7  
Old February 18th, 2009, 07:46 AM posted to microsoft.public.word.tables
Graham Mayor
external usenet poster
 
Posts: 18,297
Default Clear Form Fields

Send that message using the link on the home page of my web site.Your e-mail
message should have a toolbar option (usually looks like a paper clip) or a
menu option Insert file or similar which will allow you to select and add
the document to a message.

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org




Jamie wrote:
Hi Graham, I've been trying to use your code, but cannot seem to get
it to work. I keep trying which has only resulted in me prolonging
this new posting to you as well as admitting that I am at a loss.

My only suggestion, if you are still willing to help, is to send my
document to you. Of course, you'll need to walk me through that as
well as I have never attached a file to a post.

Oops - I don't know where that # sneaked in from
It should have read
ActiveDocument.FormFields("Bookmarkname").Result = ""

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



Graham Mayor wrote:
Having inserted the fields, you need to set their values to nul

eg

ActiveDocument.FormFields("Bookmarkname").Result = ""#

However when copying and pasting the pasted row will not have
bookmark names, so you would need to define the copied range (here
Table 1 row 2) and zero all the fields in that range - eg along the
lines of

Sub ResetFormFields()
Dim oRng As Range
Dim oFld As FormFields
Dim i As Long
Set oRng = ActiveDocument.Tables(1).Rows(2).Range
Set oFld = oRng.FormFields
For i = 1 To oFld.Count
oFld(i).Select
If oFld(i).Type = wdFieldFormDropDown Then
oFld(i).Result = oFld(i).DropDown.ListEntries(1).name
Else
oFld(i).Result = ""
End If
Next
End Sub



Jamie wrote:
Thanks for your reply Graham. I've looked at your coding for Add a
Row to a Table in a Protected Form and I am still at a loss as to
how to clear the pasted formfields. The coding that I currently
have, copies all the information including the formfields, now I
just need to clear the formfields. My columns are not the same
width and the last row is a merge of all 4 columns. I've been
pulling things out of your code to see if I can get the formfields
to clear, but unfortunately I don't know enough to be successful.

Thanks for your help.


See the examples - Add a row to a table in a protected form and
Repeat a block of formatted text and form fields based upon the
content of another form field at
http://www.gmayor.com/word_vba_examples.htm

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



Jamie wrote:
I am working in Word 2003.

I have a table made up of 3 rows, the first two rows have 4
columns, the last is one column. The table looks like this:

Row 1: Date: FormField Client Name: FormField
Row 2: Referred To: FormField Follow-Up Date:FormField
Row 3: Comments:
FormField

This is a template and when the user tabs out of the Comments
FormField I have an On Exit macro that copies the table including
the FormFields. I can't come up with coding to clear the
FormFields in the new rows. My coding for copying and pasting
the table is as follows:

CopyTable Macro

ActiveDocument.Unprotect

Selection.MoveUp Unit:=wdLine, Count:=3
Selection.MoveDown Unit:=wdLine, Count:=2, Extend:=wdExtend
Selection.Copy
Selection.MoveDown Unit:=wdLine, Count:=1
Selection.PasteAndFormat (wdTableOriginalFormatting)
Selection.MoveUp Unit:=wdLine, Count:=4

ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True

End Sub

Again this works as far as copying the table but I need the newly
pasted FormFields to be blank instead of having duplicate info
from above. Any help with this is greatly appreciated.



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 09:32 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.