Clearing Default text; MS Word

John Big Booty

AWF VIP
Local time
Tomorrow, 04:54
Joined
Aug 29, 2005
Messages
8,262
I want to clear the default text from a text form filed (MS Word). I'm guessing that I will need to write a macro to run on exit, that will do a logical test to see if text has been entered, then replace the default text or leave the text that has been input depending on the result.

I'm guessing that it should look something like

If text1 = "default text" Then
text1 = ""
Else: text1 = text1
End If

This doesn’t work and I'm not big on VBA so I'm not sure where I've gone wrong. Any help gratefully accepted.
 
Try losing the "else".

If text1 = "default text" then
text1 = ""
End If

Does that work?
 
Thanks. But no it doesn’t :confused:
 
If Me.FormFields("text1").Result = "default text" Then
Me.FormFields("text1").Result = ""
End If

HTH

Peter
 
Where are you running code from? I tested it from the code pane behind the document, if you are working from a seperate module you will need to reference the document directly instead of using the Me. keyword

Peter
 
try
If Application.ActiveDocument.FormFields("text1").Result = "default text" Then
ActiveDocument.FormFields("text1").Result = ""
End If
 

Users who are viewing this thread

Back
Top Bottom