VBA for Word 2003 - I want to delete a line break that appears

S

spenningzahl

I have a template Word VBA 2003. This template consist of many
bookmarks consisting of a paragraph text. If a bookmark is not
selected the paragraph should be deleted. Up to this point everything
is OK, but when the paragraph is deleted an extra line break appears.
As a result of this, if many bookmarks are not selected I get a lot of
spaces in the text. Does anybody know how to code this. I would be
very greatful for any help.
I have tried selection.backspace after paragraph.delete, but did not
work.

My code is:
If Opt2_5_Ja = Value Then
ActiveDocument.Bookmarks("bm2_5_2").Select
Paragraph.TypeParagraph
Else
ActiveDocument.Bookmarks("bm2_5_2").Delete
Selection.TypeBackspace
End If

Thanks. Karin
 
G

Graham Mayor

I personally prefer to add stuff into a document/form as required rather
than delete it when not, so you might find
http://www.gmayor.com/SelectFile.htm useful, however if what you are trying
to do is check the value of a variable Opt2_5_Ja and either insert a
paragraph after the associated bookmark when that variable equals a certain
value, or deletes it when not, then

Dim orng As Range
Opt2_5_Ja = InputBox("Enter Value", , 1)
Set orng = ActiveDocument.Bookmarks("bm2_5_2").Range
If Opt2_5_Ja = 1 Then
orng.InsertAfter vbCr
Else
orng.Delete
End If


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

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