HylaFAX The world's most advanced open source fax server

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: whfc: Example for Word and Mailmerge



Thoralf Freitag wrote:
> 
> Hello,
> 
> I'm not a windows-programmer, but I'm interested in for a marco, that I
> can use to send series faxes (faxes to a lot of receivers) like the
> marco for symantec-winfax. Do you have a .dot -file wich includes a
> macro that can do this?
> 
> --
> Mit freundlichen Gruessen
> 
> Thoralf Freitag

The macros that are attached assume you are using MS-Office '97
Professional

The "FaxNumber" field in your table must contain the fax number.

This is used in conjunction with the MailMerge facility.

To install these macros into your normal.dot...

	Start|Programs|MS-Word

you should have a blank document (document1.doc)

	Tools|Macro|Visual Basic Editor

select the Normal|Modules folder in the left window
then go to File|Import... and import this attachment WHFC_merge.bas


To use...

Setup a Mail Merge from a data source containing the Fax Numbers...

If you select a single merged record to fax <<ABC>>|Tools|Macro|Macros
Select SendThisFax and Run

If you want to send the lot... Tools|Macro|Macros
Select MergeFax and Run

Note...

I usually filter out data records with no valid fax number in the Mail
Merge set up





I hope this helps you...
-- 
Keith

http://members.ocean.com.au/kapgray
Attribute VB_Name = "WHFC_Merge"
Sub SendThisFax()
'
' SendThisFax 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 Box_Return As Integer

SpoolFile = "c:\windows\temp\fax\fax.ps"
Title = "Whfc OLE Macro ( Version 0.01alpha )"

faxnum = ActiveDocument.MailMerge.DataSource.DataFields("FaxNumber")

WhfcPrinter = Fax

ActivePrinter = WhfcPrinter$

Application.PrintOut FileName:="", Range:=wdPrintCurrentPage, _
    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


End Sub
Sub MergeFax()
'
' MergeFax Macro
' Macro created 08/11/98 by Keith Gray
' modified by Andrew Sharples to set <<ABC>>
'

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 Box_Return As Integer

ActiveDocument.MailMerge.ViewMailMergeFieldCodes = False
ActiveDocument.MailMerge.DataSource.ActiveRecord = wdLastRecord
Numb_Faxes = ActiveDocument.MailMerge.DataSource.ActiveRecord
ActiveDocument.MailMerge.DataSource.ActiveRecord = wdFirstRecord
For I = 1 To Numb_Faxes
SpoolFile = "c:\windows\temp\fax\fax" & I & ".ps"
Title = "WHFC OLE Mail Merge to Fax Macro"

faxnum = ActiveDocument.MailMerge.DataSource.DataFields("FaxNumber")

WhfcPrinter = "Fax"

ActivePrinter = WhfcPrinter$

Application.PrintOut FileName:="", Range:=wdPrintCurrentPage, _
    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

End Sub




Project hosted by iFAX Solutions