*************************************************
procedure sample_dde
parameter anyfile, filetype
private ddechannel, lasterr, topicstr, success, sagot,;
openfdde, app2run
if (filetype = 'DOC' or filetype = 'TXT')
wait window 'Acquiring link. Please wait...' nowait
= ddesetoption("Safety",.f.) [COLOR=green]&& turn off word's system messages[/color]
= ddesetoption("Timeout",0)
ddechannel = ddeinitiate("WinWord","System")
lasterr = ddelasterror()
app2run = 'C:\program files\microsoft office\office\winword.exe' [COLOR=green]&& haven't figured out how to automate this yet[/color]
run /n7 &app2run
ddechannel = ddeinitiate("WinWord","System")
topicstr = dderequest(ddechannel,"Topics")
if (lasterr > 0 or ddechannel = -1)
openfdde = '[FileOpen "'+alltrim(upper(anyfile))+'"]'
= ddeexecute(ddechannel,openfdde)
_cliptext=''
= ddeexecute(ddechannel,'[EditSelectAll]')
= ddeexecute(ddechannel,'[EditCopy]')
m.content = _cliptext [COLOR=green]&& store clipboard's content into a memomry variable[/color]
_cliptext='' [COLOR=green]&& empty clipboard's content[/color]
= ddeexecute(ddechannel,'[FileClose]')
= ddeexecute(ddechannel,'[FileExit]')
= ddeterminate(ddechannel)
messagebox("File successfully copied.",0+64,"Success!")
else
= ddeexecute(ddechannel,'[FileExit]')
= ddeterminate(ddechannel)
messagebox("Link to file cancelled.",0+64,"Cancelled.")
endif
else
_cliptext = "No applicable host program is available."
messagebox(_cliptext,0+64,"System")
m.content = _cliptext
replace content with _cliptext
_cliptext=''
endif
endproc