home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / os / mswindo / misc / 6448 < prev    next >
Encoding:
Internet Message Format  |  1993-01-21  |  3.9 KB

  1. Path: sparky!uunet!munnari.oz.au!ariel.ucs.unimelb.EDU.AU!ucsvc.ucs.unimelb.edu.au!mits.com.au!myrddn.mits.com.au!alistair
  2. Newsgroups: comp.os.ms-windows.misc
  3. Subject: Re: WinWord 2.0 DDE Commands
  4. Message-ID: <1993Jan22.100831.1@myrddn.mits.com.au>
  5. From: alistair@myrddn.mits.com.au
  6. Date: 22 Jan 93 10:08:31 +1000
  7. References: <431@zam103.zam.kfa-juelich.de>
  8. Nntp-Posting-Host: myrddn
  9. Nntp-Posting-User: alistair
  10. Lines: 136
  11.  
  12. In article <431@zam103.zam.kfa-juelich.de>, 
  13. vell@zelux8.zel.kfa-juelich.de (jochen vell zel/ne ++492461612335) writes:
  14.  
  15. >Can anyone tell us where to find the Command-List to Control Winword via DDE ??
  16. >Thanks in advance !!
  17.  
  18. Using the executeCommand instruction, you can send lines of WinBasic,
  19. which allow you to do anything.
  20.  
  21. I've included an example file below.  It is written in Smalltalk/V for
  22. Windows, but you should be able to figure it out without knowing
  23. Smalltalk.
  24.  
  25. Hope this helps.
  26.  
  27. Thanks,
  28.  
  29. Alistair Grant
  30.  
  31. Internet:     alistair@mits.com.au
  32. Alternate:    alistair%mits.com.au@ucsvc.ucs.unimelb.edu.au
  33. ---------------------------------------------------------------------------
  34. To execute commands in MS Excel or Word from Smalltalk is fairly
  35. straight-forward.  To open the connection, use:
  36.  
  37. <var> := DDEClient
  38.     newClient: self
  39.     application: '<executable name>'
  40.     topic: '<a String>'.
  41.  
  42. The executable must reside in your path.  An example to connect to MS
  43. Word is:
  44.  
  45. msWord := DDEClient 
  46.     newClient: self 
  47.     application: 'winword' 
  48.     topic: 'Document 1'.
  49.  
  50. The result will be nil if the connection was not established.  If you
  51. want to start the application from smalltalk try:
  52.  
  53. KernelLibrary winExec: 'winword' cmdShow: SwShownormal.
  54.  
  55. To send the command use:
  56.  
  57. <client> executeCommand: '[<command>]'.
  58.  
  59. For MS Word, <command>'s are WordBasic commands (see Help - WordBasic
  60. Programming Language).
  61.  
  62. For MS Excel, <command>'s are Excel macros (see the Excel Users
  63. Guide).
  64.  
  65. I've included a few examples below my sig.
  66.  
  67. Many thanks to the following people for all their help:
  68.  
  69.     Ron Schultz
  70.     M. v. Loewis
  71.     Rick (d88-rjo)
  72.  
  73. Hope you find this useful.
  74.  
  75. Thanks,
  76.  
  77. Alistair Grant
  78.  
  79. Internet:     alistair@mits.com.au
  80. Alternate:    alistair%mits.com.au@ucsvc.ucs.unimelb.edu.au
  81.  
  82.  
  83. ------------------------ MS Word Example ------------------------------------
  84. | msWord |
  85.  
  86. "establish a DDE link to MS-Word"
  87.  
  88. msWord := DDEClient newClient: self application: 'winword' topic: 'Document1'.
  89.  
  90. msWord isNil ifTrue:
  91.     [self error: 'Start MS Word before executing me'].
  92.  
  93. "Insert the date and time"
  94. msWord 
  95.     executeCommand: '[InsertDateTime .DateTimePic = "d MMMM, yyyy"]';
  96.     executeCommand: '[InsertPara]'.
  97.  
  98. "Insert some text"
  99. msWord
  100.     executeCommand: '[Insert "This will be a heading 1"]'.
  101.  
  102. "Set the current line style to 'heading 1'"
  103. msWord
  104.     executeCommand: '[StartOfLine]';
  105.     executeCommand: '[FormatStyle .Name="heading 1"]'.
  106.  
  107. "Move down a line"
  108. msWord
  109.     executeCommand: '[EndOfLine][InsertPara]'.
  110.  
  111. "Select Courier 14 as the current font"
  112. msWord
  113.     executeCommand: '[Font "Courier", 14]'.
  114.  
  115. "Execute the InsertDateTime macro.  If the MS Word title bar starts flashing,
  116. click on it, and then select the date format you want."
  117. msWord
  118.     executeCommand: '[ToolsMacro .Name="InsertDateTime", .Run]'.
  119.  
  120. "Select the current line"
  121. msWord
  122.     executeCommand: '[StartOfLine]';
  123.     executeCommand: '[EndOfLine 1]'.
  124.  
  125. "Close the link"
  126. msWord terminate.
  127. ---------------------------------------------------------------------------
  128.  
  129. Below are two examples of talking to Excel:
  130.  
  131. --------------------------- MS Excel Examples -------------------------------
  132. | msExcel |
  133.  
  134. msExcel := DDEClient newClient: self application: 'excel' topic: 'Sheet1'.
  135.  
  136. msExcel isNil ifTrue:
  137.     [self error: 'Start MS Excel before executing me'].
  138.  
  139. msExcel 
  140.     executeCommand: '[FORMULA("=R1C1 + 2", "R1C2")]'.
  141.  
  142. msExcel
  143.     executeCommand: '[FORMULA("1234", "R1C1")]'.
  144.  
  145. "Close the link"
  146. msExcel terminate.
  147. --------------------------- That's It ----------------------------------------
  148.