Attribute VB_Name = "FaxMerge" Sub SendThisFax() ' ' SendThisFax Macro ' Macro created 08/11/98 by Keith Gray ' Macro modified 08/06/99 by Chua Choon Hian ' To restore the original default printer ' Change fixed path to temp directory by using environment variables ' Macro modified 01/07/99 by Keith Gray ' for multi-page documents Dim whfc As Object Dim OLE_Return As Long Dim faxnum As String Dim SpoolFile As String Dim Title As String Dim WhfcPrinter As String Dim Default_Active_Printer As String Dim Box_Return As Integer SpoolFile = Environ("Temp") & "\fax.ps" Title = "Whfc Macro ( Version 1.03 )" faxnum = ActiveDocument.MailMerge.DataSource.DataFields("FaxNumber") WhfcPrinter = "HylaFAX" Default_Active_Printer = ActivePrinter ActivePrinter = WhfcPrinter$ Application.PrintOut FileName:="", Range:=wdPrintAllDocument, _ Item:=wdPrintDocumentContent, Copies:=1, Pages:="", _ PageType:=wdPrintAllPages, Collate:=True, Background:=True, _ PrintToFile:=True, OutputFileName:=SpoolFile, Append:=False Set whfc = CreateObject("WHFC.OleSrv") OLE_Return = whfc.SendFax(SpoolFile, faxnum, True) If OLE_Return <= 0 Then Box_Return = MsgBox("Error sending file", 16, Titel) Else Box_Return = MsgBox(OLE_Return, 0, Title) End If Set whfc = Nothing ActivePrinter = Default_Active_Printer$ End Sub Sub MergeFax() ' ' MergeFax Macro ' Macro created 08/11/98 by Keith Gray ' Dim whfc As Object Dim OLE_Return As Long Dim faxnum As String Dim SpoolFile As String Dim Title As String Dim WhfcPrinter As String Dim Default_Active_Printer As String Dim Box_Return As Integer ActiveDocument.MailMerge.ViewMailMergeFieldCodes = True ActiveDocument.MailMerge.DataSource.ActiveRecord = wdLastRecord Numb_Faxes = ActiveDocument.MailMerge.DataSource.ActiveRecord ActiveDocument.MailMerge.DataSource.ActiveRecord = wdFirstRecord For I = 1 To Numb_Faxes SpoolFile = Environ("Temp") & "\fax" & I & ".ps" Title = "WHFC Mail Merge to Fax Macro( Version 1.03 )" faxnum = ActiveDocument.MailMerge.DataSource.DataFields("FaxNumber") WhfcPrinter = "HylaFAX" Default_Active_Printer = ActivePrinter ActivePrinter = WhfcPrinter$ Application.PrintOut FileName:="", Range:=wdPrintAllDocument, _ Item:=wdPrintDocumentContent, Copies:=1, Pages:="", _ PageType:=wdPrintAllPages, Collate:=True, Background:=True, _ PrintToFile:=True, OutputFileName:=SpoolFile, Append:=False Set whfc = CreateObject("WHFC.OleSrv") OLE_Return = whfc.SendFax(SpoolFile, faxnum, True) If OLE_Return <= 0 Then Box_Return = MsgBox("Error sending file", 16, Titel) Else 'Box_Return = MsgBox(OLE_Return, 0, Title) End If Set whfc = Nothing ActiveDocument.MailMerge.DataSource.ActiveRecord = wdNextRecord Next I ActivePrinter = Default_Active_Printer$ End Sub