News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Masm and DDE

Started by jj2007, July 12, 2011, 04:47:42 PM

Previous topic - Next topic

jj2007

There is an old thread here but for those who like to "poke" MS Word, here a simple example:

Quoteinclude \masm32\MasmBasic\MasmBasic.inc   ; download version 12 July
  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. 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.


ToutEnMasm

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.