Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.
One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.
Public Function docPrinter(inDoc As String, inSQL As String, inDB As String, _ inCnt As Integer, inPref As Boolean) ' Prints (or opens) the selected document where ' inDoc is the fully-qualified location of the document to be printed, ' inSQL is the complete SQL statement that will retrieve the correct records, ' inDB is the fully-qualified location of the database to be queried, ' inCnt is the number of copies required (ignored if the document is to be opened), and ' inPref is true if direct printing is desired (false will open the document in Word). ' ' Examples: ' inDoc = "C:\2009 Non-Certified Contract.doc" ' inSQL = "SELECT * FROM Combined WHERE [Contract Type] in ('N')" ' inDB = "C:\$User\Business Office\EmployeeContractsData.mdb" Debug.Print inDoc Debug.Print inSQL Debug.Print inDB Dim myWord As Object Dim i As Integer Set myWord = CreateObject("Word.Application") myWord.Documents.Open inDoc, , True With myWord.ActiveDocument.MailMerge .MainDocumentType = wdFormLetters .OpenDataSource Name:=inDB, sqlstatement:=inSQL .ViewMailMergeFieldCodes = False ' Determine the actions to take (Print or Open). If inPref Then ' Print the document .Destination = wdSendToPrinter For i = 1 To inCnt .Execute pause:=False 'This will cause the output to be collated in complete sets. Next i docPrinter = "Printing is Done" Else ' Open the document with the merge completed. .Destination = wdSendToNewDocument .Execute pause:=False With myWord.Application .DisplayAlerts = wdAlertsNone .Visible = True .WindowState = wdWindowStateMaximize End With docPrinter = "Document is open" End If End With myWord.Documents(inDoc).Close savechanges:=wdDoNotSaveChanges ' Housekeeping... Set myWord = Nothing End Function