View Single Post
  #5   Report Post  
Posted to microsoft.public.word.mailmerge.fields
tgul tgul is offline
external usenet poster
 
Posts: 3
Default Word 2000 mail merge broke upgrading to 2002 sp3

Thanks. Yes this appears to be the fix. I've reproduced it in my development
environment ... Now on to the client. Thanks again.

"Peter Jamieson" wrote:

My guess is that you have this problem:

http://support.microsoft.com/kb/825765/en-us

I didn't mention it before because I thought you would already have
encountered it when working with Word 2002. But maybe that came in a later
SP.

--
Peter Jamieson
http://tips.pjmsn.me.uk

"tgul" wrote in message
...
Thanks for the reply.

The template and application code were originally developed to use Word
2000. Along the way Word was upgraded to 2002. Still worked. When sp3 for
Word 2002 was applied the code broke. The template is fine. The stored
proc
executes as always. Opening the template "manually" against the datasource
works.

I am attempting to fix it w/ Word 2003 installed on my developement
environment. I whacked the orginal Word 2000 dependencies and rebuit w/
the
2003 dependencies. Whether Word 2002 sp3 or 2003, the Execute method fails
w/
the exception "This method or property is not available because the
document
is not a mail merge main document".

-tg

"Peter Jamieson" wrote:

1. Can you clarify which versions of Word you are trying to use (you
mention
2000 and 2002, but also 2003. Is 2003 a typo?), and on which versions you
are seeing the problems?

2. Are you using the same .Name, .Querystring and .Connectstring for both
2000 and 2002? Can you discover their values immediately prior to the
..Execute?

(I suppose you have already checked:
a. that the stored procedure is still succeeding, i.e. there is no
apparent
problem in the ADO code
b. that you can still set up the mail merge main document manually to
connect to the table you are populating with your procedure
)

--
Peter Jamieson
http://tips.pjmsn.me.uk

"tgul" wrote in message
...
Hi,

I've been all over trying to apply answers to Word (2000) mail merge
related
posts w/ regard to my issue but, to no avail.

My mail merge code used to work w/ Word 2000 and 2002 on NT 4.0 sp6
before
upgrading to Word 2002 sp3 on XP. Now running the code produces a an
exception w/ the following; "This method or property is not available
because
the document is not a mail merge main document". The original code had
a
dependency upon msword9.olb. I've removed the old dependency and
generated
the wrapper classes for MS Word 2003 (msword.olb) and rebuilt. The word
template below has a datasource of a sqlserver table populated by the
stored
proc called in the code. All fields match between table and .dot.
Stepping
into the code at mailMergeMSWord.Execute, the exception is generated in
MFC
code at oledisp2.cpp OleDispatchDriver::InvokeHelperV when a call to
m_lpDispatch-Invoke is made.

Your help would be very much appreciated. Let me know if I can supply
more
info.

Regards,

tgul

My VC++ 6.0 code:

BOOL CMyClass : : PrintLetters()
{
CWaitCursor wait;
CString strSQL, strMessage;
_Application appMSWord

try
{
COleVariant vtOptional((long)DISP_E_PARAMNOTFOUND,VT_ERROR),
vtFalse((short)FALSE);

appMSWord.CreateDispatch( "Word.Application" );
CString strUserTemplatesPath =
((Options)appMSWord.GetOptions()).GetDefaultFilePa th( 15 );
Documents docsMSWord = appMSWord.GetDocuments();
_Document docTemplateMSWord;
MailMerge mailMergeMSWord;

// Generate the letters
strSQL = "{CALL GenerateLetters (" +
pPropertySheet-GetCPIString() + ", '" +
pPropertySheet-GetDDstDayofMonth() + "', '" +
pPropertySheet-GetSelectedMonthYear() + "', '" +
pPropertySheet-GetIncreaseStartDate() + "', '" +
pPropertySheet-GetIncreaseEndDate() + "')}";

CLettersSet rsLetters( GetDb() );
if ( !GetDb()-OpenRecordset( &rsLetters, FALSE,
CRecordset::forwardOnly,
strSQL,
CRecordset::readOnly |
CRecordset::executeDirect ) )
{
appMSWord.ReleaseDispatch();
return FALSE;
}

if ( rsLetters.m_RowCount 0 )
{
docTemplateMSWord =
docsMSWord.Open( COleVariant( strUserTemplatesPath +
"\\generate
letters.dot" ),
COleVariant( (short)FALSE, VT_BOOL ),
COleVariant( (short)FALSE, VT_BOOL ),
COleVariant( (short)FALSE, VT_BOOL ),
COleVariant( "" ), COleVariant( "" ),
COleVariant( (short)TRUE, VT_BOOL ),
COleVariant( "" ), COleVariant( "" ),
COleVariant( (long)0 ), COleVariant(
(long)0 ),
COleVariant( (short)TRUE, VT_BOOL ),
vtOptional,
vtOptional,
vtOptional,
vtOptional);
mailMergeMSWord = docTemplateMSWord.GetMailMerge();
mailMergeMSWord.Execute( COleVariant( (short)FALSE,
VT_BOOL ) );
docTemplateMSWord.Close( COleVariant( (long)0 ), COleVariant(
(long)0 ),
COleVariant( (short)FALSE ) );
}
else
{
strMessage += "Generate letters\n";
}
.
.
.
appMSWord.SetVisible( TRUE );
}
catch( CDBException* peDb )
{
MessageBox( peDb-m_strError, "Merge Data Error", MB_OK |
MB_ICONSTOP );
peDb-Delete();
appMSWord.ReleaseDispatch();
return FALSE;
}

appMSWord.ReleaseDispatch();

if ( strMessage != "" )
{
MessageBox( "No letters needed to be generated for:\n" +
strMessage );
}

return TRUE;
}