Delete selection of text

B

Barth Wilsey

I work with a template that has two separate documents

I wish to have either one or the other document available depending upon the
user's input. I thus wish to delete a selection of text

I have tried to delete the document that is not to be used by using an
enclosing bookmark around the text to be deleted with the code

ActiveDocument.Bookmarks("myBookmark").Range.InsertBefore ""

However, both documents remain in the Word document produced by the template

What is the best way to delete a selection of text from a document depending
upon the user's input

thanks in advance, Barth
 
P

Peter Hewett

Hi Barth Wilsey

Change your code to:

ActiveDocument.Bookmarks("myBookmark").Range.Text = vbNullString

Just a note Word does not like you deleting the final paragraph mark in a document. So if
your second "document" includes the final paragraph mark it will still be there after the
other text has been removed. So allow for this in your template design.

HTH + Cheers - Peter
 
C

Charles Kenyon

As an alternative, put both "documents" into AutoText entries and use an If
field with an AutoText field or vba to determine which one should be
displayed.

You could get your user input via an input box or if the input would
normally be shown in the document, you could use an online form to accept
the input. When the user tabs out of the form's text box (or drop-down) used
to determine which entry is displayed, the appropriate AutoText could be
shown.

For more about online forms, follow the links at <URL:
http://word.mvps.org/FAQs/Customization/FillinTheBlanks.htm> especially Dian
Chapman's series of articles.

Hope this helps,
--

Charles Kenyon

Word New User FAQ & Web Directory:
<URL: http://addbalance.com/word/index.htm>

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide)
<URL: http://addbalance.com/usersguide/index.htm>

See also the MVP FAQ: <URL: http://www.mvps.org/word/> which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
 
B

Barth Wilsey

Can you please provide the code to have the autotext entry appear in the
document, after the user selected a radio button indicating that they
preferred the text in an autotext named "MyAutotext"

thanks in advance
 
C

Charles Kenyon

I can't without knowing which implementation you are using. Generally, my
preference would be an IF field testing the value of a checkbox (formfield)
and displaying the AutoText using an AutoText field. This is not vba code.
It is a field. Writing specific code that I won't use myself and which
doesn't intrigue me goes beyond the scope of the help I'm willing to provide
here. It sounds too much like work. Sorry.
--

Charles Kenyon

Word New User FAQ & Web Directory:
<URL: http://addbalance.com/word/index.htm>

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide)
<URL: http://addbalance.com/usersguide/index.htm>

See also the MVP FAQ: <URL: http://www.mvps.org/word/> which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
 

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