Results 1 to 5 of 5

Thread: using MS Word

Threaded View

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Dec 2004
    Posts
    29

    using MS Word

    Hi,
    Im using the Word Reference to work with MS Word within my vb project. What I am doing is performing a mail merge with a word document and a text file. The data from the text file is writen into the word document. After the merge has occurde I want to print the document and close the word document at the same time. The code I use to do this is:
    Code:
     Dim cancel As Boolean = False
            Dim InternalWordApp As New Word.ApplicationClass
            Dim InternalWordDoc As New Word.Document
            Dim InternalWordDocTemp As New Word.Document
            InternalWordApp.Visible = False
            InternalWordDoc = InternalWordApp.Documents.Add("C:\Documents and Settings\60shipping\Desktop\GaugeProject\bin\label.doc")
            Try
                With InternalWordDoc.MailMerge
                    cancel = False
                    .SuppressBlankLines = True
                    InternalWordDoc.Saved = True
                    '.Destination = Word.WdMailMergeDestination.wdSendToPrinter
                    .Execute(True)
                    .Destination = Word.WdMailMergeDestination.wdSendToPrinter
                    .Application.PrintOut()
                    System.Threading.Thread.Sleep(2000)
                End With
            Catch ex As Exception
                cancel = True
                InternalWordDoc.Saved = True
                InternalWordDoc.Close()
                InternalWordDoc = Nothing
                InternalWordApp.Quit()
                InternalWordApp = Nothing
            End Try
            If (cancel = False) Then
                InternalWordDoc.Saved = True
                InternalWordDoc.Close()
                InternalWordDoc = Nothing
                InternalWordApp.Quit()
                InternalWordApp = Nothing
            End If
        End Function
    My problem is that I need to have the word document not save and print autimatically without bothering the user about anything. The things in the code kindof work but i print autimatiaclly but it still asks me to save OR it asks me if I want to print but does not ask me to save.
    Help please!

    Thank you
    Last edited by saphiroth; May 23rd, 2005 at 01:30 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width