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.WdMailMergeDestinati on.wdSendToPrinter
wordDoc.MailMerge.Execute()
wordDoc.Close(False)
wordApp.Quit(False)
Else
wordDoc.MailMerge.Destination = Microsoft.Office.Interop.Word.WdMailMergeDestinati on.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