Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Import Document into Master Document

Status
Not open for further replies.

kdrose

Technical User
Jan 14, 2009
3
US
I want to add a document (#2) to the end of my master document (#1). However, I wish to retain all of the styles of document #2 while leaving the master document styles alone. In my macro, what code will allow me to do this (i.e. supress styles update)?

krose
 
It will not, if the style names are the same.

In other words, if Doc#2 has a Yadda style, and the master doc template has a Yadda style - and they are different format - then the master doc style will apply.

How are you adding Doc#2? InsertFile? Copy/Paste?

If it is a paste, you could try using:

PasteAndFormat(wdFormatOriginalFormatting)

Frankly, while Microsoft has tried for years to get Master/Sub documents working, IMO, they never have worked well. I have tried using Master/Sub and it has never worked well.

Gerry
 
Hi krose,

As per Gerry's comments, I hope you're not using Word's Master Document 'feature' - that way lies grief (in the form of document corruption).

Assuming you've simply got two ordinary documents - a 'target document' into which you wish to import material from a 'source' document, the material from the source document will adopt the formatting of any like-named Styles in the target document, unless you're using copy & paste and use the 'Keep source formatting' option (Word 2003 & later). I believe that, when you do this via vba, the relevant code (from Word 2007) is:
Options.PasteFormatBetweenDocuments = 0
Options.PasteFormatBetweenStyledDocuments = 0

Cheers

[MS MVP - Word]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top