From a Visual Studio 2008 form I create and save a word 2003 word document for an employee selected from a dropdown list. I am trying to add a button to my form that will allow the user to view (printpreview) the document and print it if required. I am trying to work out how to printpreview the document without openning it. When I open it and then printpreview and close printpreview the document is still open which then allows the user to change it and/or they have to remember to close it.(trying to make this form idiot proof lol). here is my code at the moment.
Code:
oWord = CreateObject("Word.Application")
Try
oDoc = oWord.Documents.Open("q:\delegations\Delegation for " & CboName.Text & ".doc")
oWord.Visible = True
oDoc.PrintPreview()
Catch ex As Exception
MessageBox.Show(ex.Message)
oDoc.Close(False)
oDoc = Nothing
oWord.Application.Quit(Nothing)
oWord = Nothing
Exit Sub
End Try