Hi,
I have an application where I need to open a MS Word file, delete the contents 
of the 2nd Paragraphs in the file and create a new file.
The code I tried is like:

HWPFDocument doc = new HWPFDocument(new FileInputStream(srcFile));
FileOutputStream docOut =  new FileOutputStream(destFile);
Range r = doc.getRange();
Paragraph p = r.getParagraph(1); // because para numbering starts at 0
p.delete();
r = doc.getRange();
doc.write(docOut);  
docOut.close();  

The resulting doc file is readable in OpenOffice and has the specific paragraph 
removed (so the job is done). But, the resulting doc file cannot be opened in 
MS Word. MS Word says the file is corrupt blah blah.

Can anyone help me very fast, because Im facing a particularly very stringent 
timeline for closure?

Thanks in advance

Karthik







      Add more friends to your messenger and enjoy! Go to 
http://messenger.yahoo.com/invite/

Reply via email to