VS 2008 - > New Office 2007 Document

A

awakeSecret52

I am trying to create a Document Level office 2k7 project.
my objective is write a code in startup event of ThisDocument which will
load all content of another document say doc2.docx.

following is code I am writing

object file = "D:\\Documents and Settings\\Admin\\My Documents\\Visual
Studio 2008\\Projects\\WordDocument\\OpenContent\\Docs\\Don.docx";
object nullobj = System.Reflection.Missing.Value;
Word.Document doc = Application.Documents.Open(ref file, ref
nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref
nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref
nullobj, ref nullobj, ref nullobj);
Globals.ThisDocument.Content.Text = doc.Content.Text;
doc.Close(ref nullobj,ref nullobj,ref nullobj);

which is not really good way of programming I thnk.
I have to open new word document, load its content to current document and
close it.

what I want is..
in startup event...
I want to have loaded content of doc2.docx directly into
ThisDocument.content.text

I dont want to use another Document object.

How do I do it?
please send me as soon as possivle
 
A

Andrei Smolin [Add-in Express]

Hello,

See the XML property and InsertXML method of the Range and Selection
classes.

Regards from Belarus (GMT+2),

Andrei Smolin
Add-in Express Team Leader
www.add-in-express.com
 
C

Cindy M.

Hi =?Utf-8?B?YXdha2VTZWNyZXQ1Mg==?=,
I am trying to create a Document Level office 2k7 project.
my objective is write a code in startup event of ThisDocument which will
load all content of another document say doc2.docx.
How about the InsertFile method of the Document object. Something like

Globals.ThisDocument.Content.InsertFile(filename, ref missing, ref
missing, ref missing, ref missing);

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top