Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.
Public Sub PrintMMDoc_MS_Word(ByVal strMMDataDir As String, ByVal strMMDataFile As String, ByVal strMMDocDir As String, ByVal strMMDDocFile As String) '2007-06-03 Ted Palmer 'Dim wrdApp As Word.Application: Instantiated in class frmLogin >> cmdLogin_Click event. 'Closed & Disposed in class MainMDIFrame >> Closing event go_wrdApp.Visible = True '2007-05-24 Ted Palmer 'This Try-Catch block uses MailMerge functionality of "Word.Application" to print an instance 'of the MS-word document passed as a parameter to this subroutine and 'the MailMerge data file passed as a parameter to this subroutine. Try 'Open an existing MailMerge Main document. Dim wrdDoc As Object go_wrdApp.ChangeFileOpenDirectory(strMMDocDir) wrdDoc = go_wrdApp.Documents.Open(FileName:=strMMDDocFile) '<-- MS-Word MailMergeMain document wrdDoc.MailMerge.MainDocumentType = 0 wrdDoc.MailMerge.OpenDataSource(Name:= _ strMMDataDir & strMMDataFile, ConfirmConversions:=False, _ ReadOnly:=False, LinkToSource:=True, AddToRecentFiles:=False, _ PasswordDocument:="", PasswordTemplate:="", WritePasswordDocument:="", _ WritePasswordTemplate:="", Revert:=False, Format:=0, _ Connection:="", SQLStatement:="", SQLStatement1:="", SubType:=0) With wrdDoc.MailMerge .Destination = 0 .SuppressBlankLines = True With .DataSource .FirstRecord = 1 .LastRecord = -16 End With .Execute(Pause:=False) End With Catch ex As Exception MessageBox.Show("In Module MainModule >> Sub PrintMMDoc, there was an Error in the MailMerge process. " _ & "YOU the user probably caused this exception by closing the Microsoft Word application frame. " _ & "Please don't do this again. You probably did this during the Print Preview process. During that process. " _ & "you must close the MS-Word document and the MS-Word MailMerge Main document, but not the application frame. " _ & "When closing the MailMerge Main document, you will see 2 small x(s) in the upper right corner of the application " _ & "frame. Click ONLY the bottom x. Then minimize the application frame. To recover from this condition " _ & "and restore the printing subsystem, you must exit the AutoSubrogate(TM) program and restart it again. " _ & "Please save your work and restart the AutoSubrogate(TM) program now: " & ex.Message, _ "AutoSubrogate(TM) Exception:", MessageBoxButtons.OK, MessageBoxIcon.Stop) End Try End Sub 'PrintMMDoc_MS_Word
Join the community of 500,000 technology professionals and ask your questions.
Connect with top rated Experts
12 Experts available now in Live!