View Single Post
  #5   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Peter Jamieson Peter Jamieson is offline
external usenet poster
 
Posts: 4,582
Default Mailmerge directories not working Word 2003

It's more or less as I guessed.

However, if you set up the SQLSecurityCheck registry value as described in
the following article, your code will probably work again:

http://support.microsoft.com/kb/825765/

Peter Jamieson

"Chris" wrote in message
...
Deepest apologies for the confusion Peter (& Doug )

What the system does is take a mail merge document , create an CSV outputs
file from a database by use of various routines then merge the two
together

The user manually sets up a mail merge document using the mail merge
helper/toolbar and attaches a datasource (with no data) to add fields
into
the master document.

the program then uses this master document , creates a new datasource
(with
data ) , programatically atatches the new datasource and then merges the
master document and the new datasource .

The progam does not use Macros and only uses connection to Word via OLE
objects


You can duplicate this problems by using the code in a vb.net project

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim test As New Word.Application
Dim doc As New Word.Document
Dim ret, result As Integer


test = New Word.Application

test.Visible = True
doc = test.Documents.Open(any directory master document name )

result = doc.MailMerge.MainDocumentType()

MsgBox(Convert.ToString(result))

test.Quit()
End Sub

If you try this with a 'normal' mail merge document with a datasource
attached you will find that the document type variable is returned as -1
If you detach the datasource the document type is returned correctly

By detaching the datasource I mean I manually (using the toolbar) change
the
master document back to a normal word document then recreate it as a
directory document but when I get to Step 3 on the mail merge wizzard (
Select Reciepients ) I do not attach a datasource . This will obviously
create a Master document with no datasource

I should also point out this this error does not occur when the above code
is placed in a macro (We do not use macros for this because of problems of
shipping macros to multiple sites)

From my investigations there appears to be something either intrinsically
wrong with the way I am manually setting Master documents up and attaching
datasources using the mail merge toolbar or something intrinsically wrong
wtih Word OLE mail merge

hopefuly this has given you more info , if not feel free to email me
direct
if required or reply to this post

thanks for you interest

Chris


"Peter Jamieson" wrote:

From your description it is difficult to make sense of what is
happening -
it would help if you could say a bit more about what your software
actually
does.

A Word document can either have
a. a Mail merge document type set up (or "Normal Word Document")
b. a mail merge data source set up (in which case, there will be a mail
merge document type that is /not/ "Normal Word Document"

The user can easily set up (a) using the Mail Merge Helper in Word 2000,
or
the Wizard/Toolbar in 2003.

If the user tries to set up (b) in either program (manually or
programmatically) without first setting up (a), then Word will default to
Form Letters.

Once (b) has been set up, the only simple way for the user to get rid of
the
data source manually or programmatically is to set the Mail Merge Main
document type to Normal Word Document, in which case no information is
retained about the mail merge document type. (Actualoly if you try to do
this in Word 2003 using the old MailMergeHelper, you seem to end up with
a
mail merge main document type that displays as blank but is in fact
"Email".
Also, in Word 2003 you can programmatically close the Data Source using
the
Close method of the DataSource object/property, leaving the mail merge
main
document type intact).

So I would say that there is little difference in behaviour - unless the
user has gone to the trouble of specifying a mail merge main document
type
or the document already has a data source attached, a piece of software
cannot tell what the main document type is supposed to be.

What I suspect is happening is that
a. your software simply takes existing mail merge documents with all
their
document type and data source info. intact, and merges them
b. in Word 2003 the user has found that having an existing data source
gets
in the way, and has removed it. If they do it in the usual way, that
would
also remove the mail merge main document type information. But your
program
would not just have to restore the type information - it would also have
to
restore the data source. (which is why I can't quite see what you're
actually doing)

I think you may have to insist that your user at least sets up the mail
merge main document type for you (it can be done very easily using the
mail
merge toolbar, for example)

Peter Jamieson
"Chris" wrote in message
...
Any help/info will be of GREAT use

We have a system programatically linking to Word to create mailmerge
documents. this has always worked fine up to and including 2003. One of
our
customers has recently upgraded to Word 2003 and experienced problems
with
a
directory mail merge document .

Upon investigation I have discovered that when a mail merge master
document
has it's datasource attached Word cannot understand what kind of
document
it
is and defaults to Form Letters. With it's datasource detached then
Word
reads the document correctly

Has anybody else experienced this and have a solution for the problem

Detaching the datasource from all documents is a workaround but messy
Programmatically setting the document type in code (which does work)
is
alos not an option since the code handles both Form Letters and
Directories
and does not distinguish between them

again any help gratefully recieved