Confusion between Document Open and Document Add

D

dvdastor

Hi All,

Hoping to alleviate some confusion I have. I have a stream writer that
created a document containing numerous lines of text. I now want to
open it in Word, but with a specific Template attached. The Template
contains some macros and also limits the styles that are allowed.

When I used Documents.Open I tried Document.AttachedTemplate, but that
does not limit the styles. It brings in the Macros just fine, but the
style enforcement has not been put into effect.

If I use Document.Add, I can definitely open a document based on that
Template (with style enforcement), but then how do I get the
streamwriter text into this new document?

Thanks for any help you can provide.
 
D

Dave Lett

Hi,

You can probably use something like the following:

Selection.Range.InsertFile FileName:="C:\Test.doc"


HTH,
Dave
 
C

Cindy M -WordMVP-

Hi (e-mail address removed),

STYLES are inherited when a document is created from a template, as are
the settings. I assume we're dealing with Word 2003, here, since this is
the first version that can limit the styles?

Are you generating the file in WordProcessingML (XML)? In that case, you
need to include the style definitions + the limitations as part of the
XML you're generating.

OR, you'd need to create a document from the template, save that as XML
(so that the styles and settings are already present), then use a
transform or another XML tool (read it into a stream, edit, then write it
back out, for example) to change the document content.
Hoping to alleviate some confusion I have. I have a stream writer that
created a document containing numerous lines of text. I now want to
open it in Word, but with a specific Template attached. The Template
contains some macros and also limits the styles that are allowed.

When I used Documents.Open I tried Document.AttachedTemplate, but that
does not limit the styles. It brings in the Macros just fine, but the
style enforcement has not been put into effect.

If I use Document.Add, I can definitely open a document based on that
Template (with style enforcement), but then how do I get the
streamwriter text into this new document?

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
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