<< Click to Display Table of Contents >>

 

zetafax_logo

Example DDE macros

 


 

Windows 98

 

The following Microsoft Word macro demonstrates the use of DDE commands to submit the current document to the Zetafax server for sending by fax:

 

Sub MAIN

REM Set up DDE control of Zetafax

Conv1 = DDEInitiate("Zetafax", "Addressing")

DDEExecute(Conv1, "[DDEControl]")

 

REM Set the addressing options

DDEPoke(Conv1, "To", "123 456 7890, Sam Smith, Smith and Sons")

 

REM Set Zetafax To the default printer And Print the document

FilePrintSetup .Printer = "Zetafax    printer on ZETAFAX.SPL"

FilePrint

 

REM Submit the fax And release DDE control

DDEExecute(Conv1, "[Send][DDERelease]")  

DDETerminate(Conv1)

End Sub

 

Background printing

Please note that this macro disables the background printing feature when printing to the Zetafax printer from within a Microsoft Word macro. This is done by adding the following line:

 

ToolsOptionsPrint .Background = 0

 

You can also re-activate background printing by adding the following line to the end of your macro:

 

ToolsOptionsPrint .Background = 1

 

Windows NT

 

Because Windows NT uses a different naming convention for its printer ports it is necessary to adjust the macro shown above to accommodate for this. The simplest way to do this is to record a new macro where you select your Zetafax printer. In the example above, you need to change the FilePrintSetup call to specify the spool file path which would look something like:

 

FilePrintSetup .Printer = "Zetafax printer on NE00:"

 

This is best done by recording a simple macro within Word of you selecting the Zetafax printer and copying the resulting Word Basic code to your Zetafax DDE macro.

 

Here is an example Word for Windows macro which submits the current document to the fax server for sending by fax under Windows NT:

 

Sub MAIN

REM Set up DDE control of Zetafax

  Conv1 = DDEInitiate("Zetafax", "Addressing")

  DDEExecute(Conv1, "[DDEControl]")

REM Set Zetafax To the default printer And Print the document

  FilePrintSetup .Printer = "Zetafax printer on NE00:"

REM Disable background printing

  ToolsOptionsPrint .Background = 0

  FilePrint

REM Set the addressing options

  DDEPoke(Conv1, "To", "123 456 7890, Sam Smith, Smith & Sons")

  DDEPoke(Conv1, "Quality", "High")

  DDEPoke(Conv1, "Time", "19:00:00")

  DDEPoke(Conv1, "Attach", "infopack")

REM Submit the fax And release DDE    control

  DDEExecute(Conv1, "[Send][DDERelease]")

  DDETerminate(Conv1)

End Sub

 

Microsoft Excel

 

In Microsoft Excel, the DDEPoke instructions do not support a constant string as data. It must be a range address. So, instead of using the line:

 

DDEPoke Conv1, "From", "John Doe"

 

The instruction should appear as:

 

DDEPoke Conv1, "From", WorkSheets("Sheet1").Range("A1")

 

Here is an example Excel macro that will submit the current document to the fax server using addressing information contained in fields within an active worksheet.

 

Sub Macro1()

ZetaTalk = DDEInitiate( _ app:="Zetafax",_ topic:="Addressing")

  Application.ActivePrinter = "Zetafax printer on NE00:"

  ActiveSheet.PrintOut

  DDEExecute ZetaTalk, "[DDEControl]"

  Set RecipientName = Worksheets("Sheet1").Range("A1")

  Set OrgName = Worksheets("Sheet1").Range("B1")

  Set FaxNumber = Worksheets("Sheet1").Range("C1")

  Application.DDEPoke ZetaTalk, "Name", RecipientName

  Application.DDEPoke ZetaTalk, "Organisation", OrgName

  Application.DDEPoke ZetaTalk, "Fax", FaxNumber

 

Rem Submit the fax And release DDE control

  DDEExecute ZetaTalk, "[Send][DDERelease]"

  DDETerminate ZetaTalk

End Sub