I have a class that creates a word document from an entity in my application. I'm using the NetOffice.Word package to interact with the document. My document is created perfectly, but another blank document also appears. Can anyone suggest what I might be doing wrong? Here is a cutdown version of the class that shows the problem:
Imports NetOffice.WordApi
Namespace Sales.CRM
Friend Class CaseExporter
Private Property App As Application
Private Property Doc As Document
' Private Property Data As CaseData
Public Sub New() 'data As CaseData)
App = New Application
Doc = App.Documents.Add
Doc.Content.SetRange(0, 0)
' Me.Data = data
End Sub
Public Sub Export()
EmitTitle()
App.Visible = True
End Sub
Private Sub EmitTitle()
Dim para = Doc.Content.Paragraphs.Add()
para.Range.Style = Doc.Styles("Heading 1")
para.Range.Text = "Some Text Here"
para.Range.InsertParagraphAfter()
End Sub
End Class
End Namespace
So I'm creating a word application, adding a document to it, then adding a paragraph with some text to it. I then set the application object to visible to let the user see the document. My document becomes visible at this point, but so does another blank document. The application objects Documents.Count at this point is still returning 1