DDE Scripts

                         

Expand/Collapse all Show/Hide All

Use DDE scripts to send DDE messages to an application. Because each DDE application has its own set of DDE commands, you must reference the appropriate DDE documentation for that application. DDE commands for popular Microsoft applications such as Word, Excel, and Access can be found in the Microsoft Office Developer's Handbook from Microsoft Press.

In the DDE Script dialog box, you must first specify the DDE application with which you want to communicate. Select from the list of DDE applications defined for other Customizer link controls in the drop box or enter any valid application name (for example, C:\msoffice\winword\winword.exe). Click the File button to browse through your folders and select the application program file.

In addition to the DDE application name, you can optionally specify a topic. Topics are generally used to pass the name of a file to the DDE application. Refer to the appropriate DDE technical reference to see which topics are supported by the application.

In the DDE Script dialog box, enter any number of lines of text to be used as the DDE script. Everything entered as a DDE script must be a valid DDE command for the application.

Expand/Collapse item  Example - Creating a Microsoft Word dunning letter for a customer

An example of a DDE script that creates a Microsoft Word document with the customer name and address information from the Customer Maintenance panel is shown below. The actual script and sample Word files, SAMPLE1.txt and ARDUN.doc, are located in the MAS90\CM\SCRIPT folder.

 

AppRestore

AppShow

FileNew

ViewPage

ChDir "C:\Program Files\Sage\Sage 100\AS90\CM\Script"

InsertFile .Name = "ARDUN.doc", .Range = "Address"

InsertDateTime .InsertAsField = 1, .DateTimePic = "MMMM d, yyyy"

Insert Chr$(10)

Insert [AR_Customer_bus_CustomerName$] + Chr$(11)

Insert [AR_Customer_bus_AddressLine1$] + Chr$(11)

Insert [AR_Customer_bus_AddressLine2$] + Chr$(11)

Insert [AR_Customer_bus_AddressLine3$] + Chr$(11)

Insert [AR_Customer_bus_City$] + ", " + [AR_Customer_bus_State$] + "  " + [AR_Customer_bus_ZipCode$]

Insert Chr$(10)

Insert "Dear " + [CVS(AR_Customer_bus_ContactCode$,256)] + ","

Insert Chr$(10)

InsertFile .Name = "ARDUN.doc", .Range = "Body"

Insert "$" + [AR_Customer_bus_CurrentBalance]

Insert Chr$(10)

Insert Chr$(10)

InsertFile .Name = "ARDUN.doc", .Range = "Signature"

EditSelectAll

ShowAll (0)

StartOfDocument

Beep

 

In this example, data references such as [STP(AR_Customer_bus_CustomerName$,1)] are replaced by the actual string value enclosed in quotation marks, contained in the CUSTOMERNAME object on the panel at the time the script is executed. The STP function strips trailing spaces from the string value.

The script path reference to :\\MAS90\CM\Script in the ChDir (change directory) command must be changed to reflect the path name where the ARDUN.doc document is installed. To use a different document, remember to specify the full path name of that document in the ChDir command and change each of the InsertFile commands from "ARDUN.doc" to the correct document name.

To use the script

  1. Select Account Receivable Main menu > Customer Maintenance.

  2. In the Customer Maintenance window, click the Invoices tab.

  3. Launch the Customizer module by pressing CTRL+F9.

  4. In the Customizer Panel Selection window, select the Create a New Customized Panel option. Click OK.

  5. On the Toolbar, click the Add External Link button. In the blank area on the right side of the panel, click and drag a new button to create an external link button. The button width should be 4 and the height should be 1.50.

  6. In the External Link Definition window, in the Text field, type DDE.

  7. Click the Link Settings tab, and verify that DDE is selected as the link type.

  8. In the File Name field, click the Browse Files button and select SAMPLE1.txt in the CM\Script folder.

  9. Click the Edit Script button.

  10. In the Edit Script window, in the Application field, specify Microsoft Word by selecting the appropriate WINWORD.exe or MSWORD.exe program name. Use the browse buttons to select the application file. Do not enter the Topic field.

  11. In the DDE Script field, the ChDir script path may need to be changed based on your installation. Find the ChDir command and change ":\\MAS90\CM\SCRIPT" to point to the correct folder where the ARDUN.doc document resides.

  12. Save the changes and exit the Customizer module.

  13. In the Customer Maintenance window, select a customer.

  14. Click the Invoices tab and click the DDE link button.

Microsoft Word begins execution and the DDE script automatically creates the dunning letter document with information for the current customer.