Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delete line on a specific page in word.

Status
Not open for further replies.

tyang01

Technical User
Feb 1, 2007
46
US
Is there anyway to delete a specific line on a page in a Word Document?
 




Hi,

When you refer to a specific line on a page, do you mean a specific line NUMBER or specific TEXT?

Skip,
[sub]
[glasses] When a diminutive clarvoyant had disappeared from detention, headlines read...
Small Medium at Large[tongue][/sub]
 
I meant a specific line number and along with it the text in that line.
 





You do realize that the line number in YOUR document and the line number in MY document may be different, depending on the printer driver each of us is using.

Skip,
[sub]
[glasses] When a diminutive clarvoyant had disappeared from detention, headlines read...
Small Medium at Large[tongue][/sub]
 
It's okay I found something that will work for me. Thanks guys.
 
tyang01, we need more information to go any further on this.

If this is a repeating need, then the easiest, best, solution may be to bookmark the "line" in question. When requried, go to that bookmark and delete it.

"I meant a specific line number and along with it the text in that line. "

As Skip points out, "specific line number" is actually a meaningless phrase within the overall context of Word. Unless a chunk of text is explicitly marked (with a bookmark) that chunk could very well be a different "line" number. Word derives ALL layout from the printer driver. The same document may have different "line" numbers on different machines.

Again, if this is something that requires repeatability (is that a real word?), then using a bookmark would take care of it. If it is a one-time thing, or even a once-in-a-while thing...then, as Tony mentions, select it and press Del.

faq219-2884

Gerry
My paintings and sculpture
 
It's also polite and helpful to tell everyone what the solution was, when you find an answer to your own problem. Someone else might want to use it.

[yinyang] Madawc Williams (East Anglia, UK). Using Windows XP & Crystal 10 [yinyang]
 
Well my solution to the problem was just did a count on the paragraph markers until I find that specific line. inserted the count into the paragraph# variable.

Dim myRange As Range
Set myRange = ActiveDocument.Paragraphs(paragraph#).Range

myRange.Paragraphs(1).Range.delete
 
I guess the challenge is to find a less efficient method.

How about you tell us what it is that you want to do and what criteria you use to identify the 'line' - or is it a paragraph? - and somebody will give you a better solution.

Enjoy,
Tony

------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.

Professional Office Developers Association
 
I know but that's the only solution that worked to delete the lines of text in the document. So I'm just going with it.

Thanks for all the replies.
 
I know but that's the only solution that worked to delete the lines of text in the document. So I'm just going with it.

The "only" solution? Sorry, but that is utter nonsense.

However, you seem to want to persist in ignoring any suggestions regarding this, so...hey...if you are happy with it, who is to argue?

I hope nothing is ever changed (added/deleted), or the document is never opened on a different machine. Your hard-coded number could very well be off.

BTW: unless you need it for something else - what I don't know, as you delete it - declaring, setting your range object is rather pointless.
Code:
ActiveDocument.Paragraphs(#).Range.Delete

does it all on its own, without using a Range object.

So...you manually count the paragraphs to pin-point the desired paragraph, then hard-code that to delete the paragraph by code. As Tony pointed out, the challenge is to find a less efficient method.

Only solution? Hardly. I suggested using a bookmark, but you ignore that. Using a bookmark would allow you to delete ANY set piece of text, regardless of where it is, where it may be moved to, or how Word may place it using a different printer driver.

Whatever...

faq219-2884

Gerry
My paintings and sculpture
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top