On Tue, 27 Apr 2004, Ryan Ackley wrote:
> I saw, thanks Nick. Does the delete method work?
Addressing this specifically:
I have a word document with four paragraphs. The second contains the text
"{delete me}". The third contains some bold text.
I'm trying two different ways to trash the second paragraph, having found
it. The first, deleting the paragraph object, doesn't remove the
paragraph, but does remove the boldening from the third paragraph. The
second, grabbing the paragraph start and end, creating a new range, then
deleting this, removes paragraphs 3 and 4, and the bold them applies to
part of the second paragraph....
Relevent code is:
int numParagraphs = r.numParagraphs();
int p_s = 0;
int p_e = 0;
boolean useParaDel = true;
for(int i=0; i < numParagraphs; i++) {
Paragraph p = r.getParagraph(i);
String text = p.text();
if(text.trim().length() == 0) { continue; }
System.out.println(i + "\t" + p.text() + "\n\n");
if(text.indexOf("{delete me}") > -1) {
System.out.println("Found, deleting");
if(useParaDel) { p.delete(); }
p_s = p._start;
p_e = p._end;
}
}
Range rt = new Range(p_s,p_e,r);
if(! useParaDel ) { rt.delete(); }
Should either of these deleting methods work? (I can send you the starting
word doc and/or submit it to bugzilla if that'd help)
Thanks
Nick
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]