Loosing data connection when automating merge

J

Jack

When automating the merge of a doc via VS.NET, I am loosing the data
connection with in the doc and thus getting erroneous results. Has anyone
seen this behavior or know where to point me?

Here is a simplified call to the doc:

Private Sub PrintReport()

Dim wordapp As ApplicationClass
Dim wordDoc As Document
wordapp = New ApplicationClass
Dim sPages As String
Dim sfullpath As String = "C:\Projects\TestWinApp\Output\in\test3.doc"
If File.Exists(sfullpath) Then File.Delete(sfullpath)

If File.Exists("C:\Projects\TestWinApp\newdoc.doc") Then
wordDoc =
wordapp.Documents.Open("C:\Projects\TestWinApp\newdoc.doc")
wordDoc.MailEnvelope "MergeUpdate")
sPages =
wordDoc.Bookmarks.Item("Print").Range.ComputeStatistics(WdStatistic.wdStatisticPages)
wordDoc.PrintOut(background:=True, Range:=4,
outputfilename:=sfullpath, Pages:="1-" & sPages)
wordDoc.Close(True)
wordDoc = Nothing ' close doc
wordapp.Quit()
wordapp = Nothing ' close word
End If
lblMain.Text += "File complete"
End Sub
 
J

Jack

Please ignore the "wordDoc.MailEnvelope 'MergeUpdate')" in the previous post.
This was the beginnings of a solution search that I forgot to delete from
the code.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top