erase field textbox

M

mino

I'm italian and I apologised for my english and I'd like ask a
question.
In my hospital I have a discharge template with five textbox fields
that I fill every time with medical information.
When I dismiss the next patient I need to delete the content of the
five textbox (pre-existing one) by macro or vba.
I tried with textbox1.text = "" but doesn't work.

I appreciate any possible help. Ciao from Italy
 
S

Suzanne S. Barnhill

Assuming this is a protected form, what you should really be using is a
template (.dot or .dotx). Create a new document based on the template each
time, and the form fields will be empty. That said, in most versions of Word
I believe you can clear the fields by unprotecting and reprotecting the form
(using Unprotect/Protect Document, not the Lock button on the Forms
toolbar).

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
http://word.mvps.org
 
M

mino

Assuming this is a protected form, what you should really be using is a
template (.dot or .dotx). Create a new document based on the template each
time, and the form fields will be empty. That said, in most versions of Word
I believe you can clear the fields by unprotecting and reprotecting the form
(using Unprotect/Protect Document, not the Lock button on the Forms
toolbar).

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USAhttp://word.mvps.org

Thanks for yuor answer.I have to tell you another information I hope
very useful.
Yes I'm using a template dotx.The problem is that when the document
was docm(Word 2007) all was working fine with
Public Sub macro1()
With ThisDocument
.TextBox1.Text = ""
.TextBox2.Text = ""
.TextBox3.Text = ""
.TextBox4.Text = ""
.TextBox5.Text = ""

End With
End Sub
After the conversion in template the routine see above doesn't work
anymore.
I say goodbye to you.
 
J

Jay Freedman

Thanks for yuor answer.I have to tell you another information I hope
very useful.
Yes I'm using a template dotx.The problem is that when the document
was docm(Word 2007) all was working fine with
Public Sub macro1()
With ThisDocument
.TextBox1.Text = ""
.TextBox2.Text = ""
.TextBox3.Text = ""
.TextBox4.Text = ""
.TextBox5.Text = ""

End With
End Sub
After the conversion in template the routine see above doesn't work
anymore.
I say goodbye to you.

In this macro, try replacing ThisDocument with ActiveDocument.

Whether that works or does not, what Suzanne told you is still true.
But I will add that when you "use a template", that means using the
New command on the File (or Office button) menu instead of the Open
command. When you do that, Word will create a new document based on
the template instead of opening the template itself. The fields in
that document will automatically be empty, without the need for a
macro.
 
M

mino

In this macro, try replacing ThisDocument with ActiveDocument.

Whether that works or does not, what Suzanne told you is still true.
But I will add that when you "use a template", that means using the
New command on the File (or Office button) menu instead of the Open
command. When you do that, Word will create a new document based on
the template instead of opening the template itself. The fields in
that document will automatically be empty, without the need for a
macro.

--
Regards,
Jay Freedman
Microsoft Word MVP        FAQ:http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroupso all may benefit.

Thanks very much,I follow your advice and all work very well.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top