home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-386-Vol-2of3.iso / a / am-21b.zip / MACROS.TX_ < prev    next >
Text File  |  1993-01-28  |  3KB  |  87 lines

  1. The following two macros are Word For Windows 2.0 macros
  2. that you can play with.  They illustrate how to use the
  3. new DDE protocol.  If you are not familiar with programming
  4. Word For Windows macros, its best not to try to get involved
  5. with this file.
  6.  
  7. ==============================================================
  8.  
  9. This is the SelectNameGetAddress macro.  It should be self
  10. explanatory if you run it.
  11.  
  12. Sub MAIN
  13.     On Error Goto Done
  14.  
  15.     ChanNum = DDEInitiate("address", "DDE.ADD")
  16.     NotDone = 1
  17.  
  18.     Dim NumNames$(5)
  19.     Dim ListName$(64)
  20.  
  21.     NumNames$ = DDERequest$(ChanNum, "c [Current List]")
  22.  
  23.     ListName$ = "List: " + DDERequest$(ChanNum, "l")
  24.  
  25.     Dim ListBox1$(Val(NumNames$))
  26.  
  27.     ListBox1$(0) = ""
  28.  
  29.     wItems = Val(NumNames$)
  30.  
  31.     ListBox1$(0) = DDERequest$(ChanNum, "uf [Current List] %NAME")   
  32.     ctr = 1
  33.     While ctr < wItems
  34.         ListBox1$(ctr) = DDERequest$(ChanNum, "un")
  35.         ctr = ctr + 1
  36.     Wend
  37.  
  38.     Begin Dialog UserDialog 420, 160, "Choose Name"
  39.     OKButton 320, 30, 88, 21
  40.     CancelButton 320, 59, 88, 21
  41.                 Text 20, 12, 380, 12, ListName$
  42.      ListBox 20, 30, 289, 124, ListBox1$(), .Index
  43.   End Dialog
  44.       
  45.    Dim TestDialog As UserDialog
  46.    Dialog TestDialog
  47.    If ListBox1$(TestDialog.Index) <> "" Then     Insert DDERequest$(ChanNum, "uf [Current List] " + \
  48.                                                             "[" + ListBox1$(TestDialog.Index) + "]" + \
  49.                                                             "%NAME%CR" + \
  50.                                                             "%A1%CR%A2%CR%A3%CR" + \
  51.                                                             "%CITY% %ST%, %ZIP%CR")
  52.  
  53. Done:
  54.    DDETerminate(ChanNum)
  55. End Sub
  56.  
  57. =========================================================================
  58.  
  59. This is a macro that gets all the names from a specified list.
  60.  
  61. Sub MAIN
  62.  
  63.     Dim Data$(500)
  64.  
  65.    ChanNum = DDEInitiate("address", "DDE.ADD")
  66.    Insert DDERequest$(ChanNum, "uf [All Addresses] [A Luther] %SAL% %FN" + \
  67.                                                             "% %LN%CR%A1" + \
  68.                                                             "% %A2%CR%A3%CITY% %ST%, %ZIP%CR" + \
  69.                                                             "%Home Phone: %HP%CR" + \
  70.                                                             "%Work Phone: %WP% %Ext. %WE%CR" + \
  71.                                                             "%Fax Phone: %FP%CR" + \
  72.                                                             "%His Birthday: %HISB%CR" + \
  73.                                                             "%Her Birthday: %HERB%CR" + \
  74.                                                             "%Anniversary: %AN%CR" + \
  75.                                                             "%Comment: %CMT%CR%CR")
  76.  
  77.  
  78.    NotDone = 1
  79.  
  80.    While NotDone
  81.       Data$ = DDERequest$(ChanNum, "un")
  82.       If Data$ = "" Then NotDone = 0 Else Insert Data$
  83.    Wend
  84.  
  85.    DDETerminate(ChanNum)
  86. End Sub
  87.