PC Review


Reply
Thread Tools Rate Thread

Automateing a Word Mail Merge

 
 
=?Utf-8?B?S2F5dHJpbQ==?=
Guest
Posts: n/a
 
      14th Jul 2004
I have an application that puts data into an Excel spreadsheet. It then opens a Word doc that reads the data and either prints the resulting form letters or keeps the file open for viewing. This uses Office XP and worked fine until I applied SP3. now it crashes with the following error. "Requested object is not available" The crash occurs when I try to set the MailMerge.Destination. If I skip setting the destination the following message appears: "This method or property is not available because the document is not a mail merge main document." This tells me that I am now missing several steps.

Here is the code block that I have been using:

Dim wordApp As New Microsoft.Office.Interop.Word.Application
wordApp.Visible = True
Dim wordDoc As Microsoft.Office.Interop.Word.Document = wordApp.Documents.Open("formletter.doc", , True, False)

'Output the Mail Merge to the chosen destination
Try
If bolOutputPrinter Then
wordDoc.MailMerge.Destination = Microsoft.Office.Interop.Word.WdMailMergeDestination.wdSendToPrinter
wordDoc.MailMerge.Execute()
wordDoc.Close(False)
wordApp.Quit(False)
Else
wordDoc.MailMerge.Destination = Microsoft.Office.Interop.Word.WdMailMergeDestination.wdSendToNewDocument
wordDoc.MailMerge.Execute()
wordDoc.Close(False)
End If
Catch e As Exception
MessageBox.Show("An Exception Occurred in application, Please notify DB Admin of the following message: " & Chr(13) & Chr(13) & e.ToString, "Error in Application")
End Try


I have made sure that I am using the latest PIAs by downloading them from the following site: http://www.microsoft.com/downloads/d...displaylang=en and installing them as per the instructions. I also refreshed the refferences in my application. I plan to use this type of reporting system in the future as it is easy to set up. However I need to know where I have gone wrong and what I need to do different when we migrate to Office 2003.

Please help,
Kaytrim


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Mail-Merge: Can we have master detail relationship or multiple entities in word Mail-Merge? gmax2006 Microsoft Word Document Management 1 28th Mar 2007 06:28 PM
Word 2000 Mail Merge: Word found no mail merge fields Brian Harvey Microsoft Excel Discussion 1 23rd Nov 2006 07:59 PM
Insert Merge Field problem with Word-Mail Merge from Excel documen =?Utf-8?B?QXVndXN0YSBFLg==?= Microsoft Word Document Management 2 20th Jun 2005 10:59 AM
Automateing a Word Mail Merge =?Utf-8?B?S2F5dHJpbQ==?= Microsoft VB .NET 1 14th Jul 2004 04:22 PM
Mail Merge using MS Word and Outlook-Unable to merge Contacts data John O'Grady Microsoft Outlook Contacts 0 24th Jul 2003 12:09 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:29 AM.