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
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