If text box is blank...

J

Julie T.

Hi, thanks for reading my question.

I have a template which has a user form. On the user
form, I have a text box that is optional (address 2). If
the user skips over this text box, I want to be able to
delete the paragraph in the addressee area, otherwise if
there is no suite number, the document comes out like
this:

Joe Smith
100 Main Ave

Denver, CO 80202

How can I say, "If there is no input for the Add2
textbox, delete the paragraph mark at the Add2 bookmark"?

Any help is greatly appreciated.

Julie
 
J

Jonathan West

Julie T. said:
Hi, thanks for reading my question.

I have a template which has a user form. On the user
form, I have a text box that is optional (address 2). If
the user skips over this text box, I want to be able to
delete the paragraph in the addressee area, otherwise if
there is no suite number, the document comes out like
this:

Joe Smith
100 Main Ave

Denver, CO 80202

How can I say, "If there is no input for the Add2
textbox, delete the paragraph mark at the Add2 bookmark"?

Any help is greatly appreciated.

Julie

Hi Julie,

Try this

If Len(Add2.Text) = 0 Then
ActiveDocument.Bookmarks("Add2").Range.Paragraphs(1).Range.Delete
End If
 
J

Jean-Guy Marcil

Bonjour,

Dans son message, < Julie T. > écrivait :
In this message, < Julie T. > wrote:

|| Hi, thanks for reading my question.
||
|| I have a template which has a user form. On the user
|| form, I have a text box that is optional (address 2). If
|| the user skips over this text box, I want to be able to
|| delete the paragraph in the addressee area, otherwise if
|| there is no suite number, the document comes out like
|| this:
||
|| Joe Smith
|| 100 Main Ave
||
|| Denver, CO 80202
||
|| How can I say, "If there is no input for the Add2
|| textbox, delete the paragraph mark at the Add2 bookmark"?
||

Something like:
(I use the Trim function in case the user has inadvertently typed in some
spaces, or incompletely deleted an entry)

'_______________________________________
If Trim(Add2.Value) = "" Then
With ActiveDocument.Bookmarks("Add2")
.Range.Paragraphs(1).Range.Delete
.Delete
End With
End If
'_______________________________________

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
J

Jay Freedman

Julie said:
Hi, thanks for reading my question.

I have a template which has a user form. On the user
form, I have a text box that is optional (address 2). If
the user skips over this text box, I want to be able to
delete the paragraph in the addressee area, otherwise if
there is no suite number, the document comes out like
this:

Joe Smith
100 Main Ave

Denver, CO 80202

How can I say, "If there is no input for the Add2
textbox, delete the paragraph mark at the Add2 bookmark"?

Any help is greatly appreciated.

Julie

Hi Julie,

If Add2.Text = "" Then
With ActiveDocument.Bookmarks("Add2")
.Range.Paragraphs(1).Range.Delete
.Delete ' remove the bookmark itself, too
End With
Else
ActiveDocument.Bookmarks("Add2").Range.Text = Add2.Text
End If
 

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