.net - declaring New instance of WordprocessingDocument using OpenXML -


i attempting use open xml first time. following tutorial found here http://www.codeproject.com/articles/36694/creation-of-a-word-2007-document-using-the-open-xm. when declare variable new wordprocessingdocument receive error:

"type wordprocessingdocument.create undefined".

imports documentformat.openxml imports documentformat.openxml.wordprocessing imports documentformat.openxml.packaging  partial class test  public sub button1_click(byval sender object, byval e system.eventargs) handles button1.click     makedoc("file.docx") end sub  private sub makedoc(byval documentfilename string)     using mydoc new wordprocessingdocument.create(documentfilename, wordprocessingdocumenttype.document)         dim mainpart maindocumentpart = mydoc.addmaindocumentpart()         'create document tree simple document.          mainpart.document = new document()         'create body (this element contains         'other elements want include          dim body new body()         'create paragraph          dim paragraph new paragraph()         dim run_paragraph new run()         ' want put text output document          dim text_paragraph new text("hello world!")         'append elements appropriately.          run_paragraph.append(text_paragraph)         paragraph.append(run_paragraph)         body.append(paragraph)         mainpart.document.append(body)         ' save changes main document part.          mainpart.document.save()     end using 

you can't create new instance of worddocumentprocessing this. constructor protected.

you need call create or open method :

using mydoc wordprocessingdocument = wordprocessingdocument.create(documentfilename, wordprocessingdocumenttype.document)    ... end using 

Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -