removing lines / paragraphs

C

Chris

Hi I have a word document that is being used as a standard letter. The word
document has bookmarks and is linked to access.

The standard word document has the company name, address and contact details
at the top of the page, however, when this is printed to headed paper I
would like to remove the company details.

so how would I write the code to delete the top 7 lines / 1st paragraph in
word?
 
G

Graham Mayor

Provided the text you want to 'remove' is indeed text then select the text
and bookmark it - call the bookmark 'hidden'.
The following macro will then give you the option to hide the text (by
formatting the font as white) or not.

Dim sQuery As String
sQuery = InputBox("Hide letterhead text?" & vbCr & _
"Enter anything but 'Y' to restore the text", "Hide Text", "Y")
With Selection
.GoTo What:=wdGoToBookmark, Name:="Hidden"
If sQuery = "Y" Then
.Font.Color = wdColorWhite
Else
.Font.Color = wdColorAutomatic
End If
.EndKey Unit:=wdStory
End With

Formatting the text as white coloured will leave retain the space the text
occupied.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
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