AdrianJohnsonCA
Fri Jul 11 11:51:05 PDT 2008
Thanks Cindy - that works fine, although obviously doesn't save any of the
document's other data (eg password protection etc). Note that the range
object in the Word 2003 document object model doesn't have an XML property
(2007 does). The get_XML method appears to do exactly the same thing, though
MS documentation says you're not meant to use it.
"Cindy M." wrote:
> Hi =?Utf-8?B?QWRyaWFuIEpvaG5zb24sIENB?=,
>
> > I'd like to use MS Word as a text editor and store the data as a byte[]
> > within a name in Excel. I'd like to embed a Word document in an Excel file
> > so the user can create rich 'how-to' documentation which gets transported
> > with the workbook.
> > Document's SaveAs and Open methods require a filename to be passed in, and a
> > Document object is not serializable.
> > To save the file, I could save the Document as a temporary file as an
> > intermediary, and then open up that file as a FileStream which I could then
> > convert to a byte array. However, creating the FileStream doesn't work if
> > the Document is still open in Word as it is being used by another process.
> > Outlook seems to be able to use Word as a text editor for composing email
> > messages, I'd like to do something similar.
> > Any ideas? I'm using C# in VS 2008 Professional, and Office 2003.
> >
> About the only thing I can think of is to extract the information from the
> document range using the XML property of the Range object into a String. You
> can stream/serialize this with no problems.
>
> 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 :-)
>
>