Adding headers to Word documents

Nov 30, 2015 at 5:11 PM
Edited Dec 1, 2015 at 11:27 PM
I have an application that spits out formatted Word documents. I'm trying to edit the headers, but haven't been able to do it. Is anyone able to help?

Here's the code so far, where pHeader is the XWPFParagraph in the document I want to add:

Dim hfpPolicy As New XWPFHeaderFooterPolicy(doc)
hfpPolicy.CreateHeader(NPOI.OpenXmlFormats.Wordprocessing.ST_HdrFtr.default, pHeader)

but I get an object reference not found. Any help would be greatly appreciated.
Dec 3, 2015 at 4:39 PM
Anyone know the difference between a XWPFParagraph and a XWPFParagraph() as a data type?
It would seem to imply an array of some kind...

Example I understand:
//creates a paragraph
XWPFParagraph paragraph = document.createParagraph();

Unsure:
XWPFParagraph p1 = new XWPFParagraph(ctP1);
XWPFParagraph[] pars = new XWPFParagraph[1];
pars[0] = p1;

How do I convert a XWPFParagraph to a XWPFParagraph() requested by headerFooterPolicy.createHeader(STHdrFtr.DEFAULT, newparagraphs)?