The MASM Forum Archive 2004 to 2012

General Forums => The Workshop => Topic started by: jj2007 on July 12, 2011, 04:47:42 PM

Title: Masm and DDE
Post by: jj2007 on July 12, 2011, 04:47:42 PM
There is an old thread here (http://www.masm32.com/board/index.php?topic=7895.0) but for those who like to "poke" MS Word, here a simple example:

Quoteinclude \masm32\MasmBasic\MasmBasic.inc   ; download version 12 July (http://www.masm32.com/board/index.php?topic=12460)
  Init
  SendWordCommands INIT      ; replace D: with your Masm32 drive
  .if eax
      SendWordCommands Chr$("[FileNewDefault:InsertFile ", 34, "D:\Masm32\include\Windows.inc", 34,\
      ":InsertFile ", 34, "D:\Masm32\include\WinExtra.inc", 34, ":SetDocumentDirty 0]")
  .else
      MsgBox 0, "No connection to Word", "Sorry", MB_OK
  .endif
  SendWordCommands EXIT
  Print "bye"
  Exit
end start

MS Word must be running. The proggie creates a new file and inserts Windows.inc, then WinExtra.inc; finally, it sets the document status to clean.

Hint: You may need the WordBasic help file (http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=7035). SendWordCommands works just fine with MS Word 2007 (could not test later versions, and could not test on Win 7), but the WordBasic language is, well, ancient is probably the right word :bg

Actually, I lost some time chasing a bug: the second insert, WinExtra.inc, had font MS Gothic, in contrast to Courier for the first one. Varrrry strange :dazzled:
The mystery became clearer when I created the exact macro that MB sends via DDE as a standalone Word macro - and voilà, same bug, so DDE was innocent. Google for insertfile changes font, apparently it's one of M$ "why should we bother" exercises.

Title: Re: Masm and DDE
Post by: ToutEnMasm on July 12, 2011, 06:11:42 PM
I have modify the old thread .The old file (on my site) wasn't downloadable.
I used the new downloadable file as a test one.Some new codes can be here.