In case somebody needs to use MS Winword in Natural program
here is small example…
DEFINE DATA LOCAL
1 #myWordApplication HANDLE OF OBJECT
1 #myWordFile HANDLE OF OBJECT
1 #WDocuments HANDLE OF OBJECT
1 #mySelection HANDLE OF OBJECT
1 #end (a1)
1 #fileName (a20) init <'d:\123.doc'>
1 #dummy (a20)
END-DEFINE
repeat while #end <> '6'
input /
/ '(0) Create new winword doc'
/ '(1) Open existing winword file' #fileName (ad=m)
/ '(2) Show Winword editor'
/ '(3) Hide Winword editor'
/ '(4) Insert some data in current document'
/ '(5) Print document'
/ '(6) End program'
/ ' What do you want to do today (0-6)' #end
if #end = '0' then
CREATE OBJECT #myWordApplication OF CLASS "Word.Application"
#WDocuments := #myWordApplication.Documents
SEND "Add" TO #WDocuments with #filename
RETURN #myWordFile
move #myWordFile.name to #dummy
write 'Открытый файл' #dummy
end-if
if #end = '1' then
CREATE OBJECT #myWordApplication OF CLASS "Word.Application"
#WDocuments := #myWordApplication.Documents
SEND "Open" TO #WDocuments with #filename
RETURN #myWordFile
move #myWordFile.name to #dummy
write 'opened file name' #dummy
end-if
if #end = '2' then
move true to #myWordApplication.<<Visible>> /* покажем на экране
end-if
if #end = '3' then
move false to #myWordApplication.<<Visible>> /* спрячем
end-if
if #end = '4' then
send "Selection" to #myWordApplication return #mySelection
send "TypeText" to #mySelection with 'привет'
end-if
if #end = '5' then
send "PrintOut" to #myWordApplication /* печатаем
end-if
if #end = '6' then
SEND "quit" TO #myWordApplication with false /* сохранять не будем
#myWordApplication := null-handle
end-if
end-repeat
end