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.Desti nation. 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.Offic e.Interop.Word. Application
wordApp.Visible = True
Dim wordDoc As Microsoft.Offic e.Interop.Word. Document = wordApp.Documen ts.Open("formle tter.doc", , True, False)
'Output the Mail Merge to the chosen destination
Try
If bolOutputPrinte r Then
wordDoc.MailMer ge.Destination = Microsoft.Offic e.Interop.Word. WdMailMergeDest ination.wdSendT oPrinter
wordDoc.MailMer ge.Execute()
wordDoc.Close(F alse)
wordApp.Quit(Fa lse)
Else
wordDoc.MailMer ge.Destination = Microsoft.Offic e.Interop.Word. WdMailMergeDest ination.wdSendT oNewDocument
wordDoc.MailMer ge.Execute()
wordDoc.Close(F alse)
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
Here is the code block that I have been using:
Dim wordApp As New Microsoft.Offic e.Interop.Word. Application
wordApp.Visible = True
Dim wordDoc As Microsoft.Offic e.Interop.Word. Document = wordApp.Documen ts.Open("formle tter.doc", , True, False)
'Output the Mail Merge to the chosen destination
Try
If bolOutputPrinte r Then
wordDoc.MailMer ge.Destination = Microsoft.Offic e.Interop.Word. WdMailMergeDest ination.wdSendT oPrinter
wordDoc.MailMer ge.Execute()
wordDoc.Close(F alse)
wordApp.Quit(Fa lse)
Else
wordDoc.MailMer ge.Destination = Microsoft.Offic e.Interop.Word. WdMailMergeDest ination.wdSendT oNewDocument
wordDoc.MailMer ge.Execute()
wordDoc.Close(F alse)
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