embedding subdocuments (1:n relations)

E

Erwin

I want to make a 1:n relationship with mail-merge
documents by embedding a subdocument (also an mail-merge
document) in a main-document.
// JScript
...
// mainRng is the range of the main document
// subRng is the range of the sub document
mainRng.Subdocuments.AddFromRange(subRng);
...
But when I do so, I get the error message:
The specified range doesn't belong to this
document/article (free translated from the german error
msg).

When I try to make it with text replacement:
// JScript
...
mainRng.InsertAfter(subRng.FormattedText);
...
I lose all formattings - only pure Text will be inserted.
That's not what I want.

Is there an other solution for my problem, where I can
insert the hole sub-document (with all formattings,
tables, etc.) in the main-document?
 
C

Cindy M -WordMVP-

Hi Erwin,

Right, couple of points, here :)

1. You do NOT want to use the Master-/Subdoc feature
(Zentral-/Filialdok). This is not "stable", and is anyway
not for this purpose. Use InsertFile, instead

2. For future reference: the syntax you're trying to use
does NOT bring in an outside file, but is meant to create a
subdocument from text already in the "Master doc". What
you'd be looking for is AddFromFile.

3. Whichever approach isn't going to get you a 1:n mail
merge result. Take a look under Special Merges in the mail
merge FAQ on my website for the three basic approaches
(four, if we're talking Word 2002 or later) you can use to
build 1:n documents in Word.
I want to make a 1:n relationship with mail-merge
documents by embedding a subdocument (also an mail-merge
document) in a main-document.
// JScript
...
// mainRng is the range of the main document
// subRng is the range of the sub document
mainRng.Subdocuments.AddFromRange(subRng);
...
But when I do so, I get the error message:
The specified range doesn't belong to this
document/article (free translated from the german error
msg).

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update
Sep 30 2003)
http://www.mvps.org/word

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

Guest

Hello Cindy,

thank's for your help - by the way I have already read
your articles published on the msdn-homepage; a
recommendation for every coder working with mail-merge!! -
but also not the solution for me :-(

The AddFromFile method call returns an other error-msg:
The AddFromFile-method or property isn't available,
because structuring view is not activated.

??!!
 
C

Cindy M -WordMVP-

The AddFromFile method call returns an other error-msg:
The AddFromFile-method or property isn't available,
because structuring view is not activated.
You have to be in the OUTLINE view (Gliederungsansicht) in
order to do anything using Master Doc commands.

But I still say you should NOT be trying to use this. If
you want to bring in an outside file, you really should use
InsertFile...

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update
Sep 30 2003)
http://www.mvps.org/word

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

Guest

yes, now it works, great!!

best thanks.
-----Original Message-----
You have to be in the OUTLINE view (Gliederungsansicht) in
order to do anything using Master Doc commands.

But I still say you should NOT be trying to use this. If
you want to bring in an outside file, you really should use
InsertFile...

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update
Sep 30 2003)
http://www.mvps.org/word

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