35 lines
1,002 B
Text
35 lines
1,002 B
Text
#include "disphelper/disphelper.bi"
|
|
|
|
dhInitialize(True)
|
|
dhToggleExceptions(True)
|
|
|
|
Dim As IDispatch Ptr wordApp, document, content
|
|
Dim As IDispatch Ptr paragraphs, paragraph, rnge
|
|
|
|
OleInitialize(NULL)
|
|
dhCreateObject("Word.Application", NULL, @wordApp)
|
|
dhPutValue(wordApp, ".Visible = %b", True)
|
|
dhGetValue("%o", @documents, wordApp, ".Documents")
|
|
dhCallMethod(documents, "Add", @document)
|
|
dhGetValue("%o", @content, document, ".Content")
|
|
dhGetValue("%o", @paragraphs, content, ".Paragraphs")
|
|
dhCallMethod(paragraphs, "Add", @paragraph)
|
|
dhGetValue("%o", @rnge, paragraph, ".Range")
|
|
dhPutValue(rnge, ".Text = %s", "This is a Rosetta Code test document.")
|
|
|
|
Sleep 10000 ' Wait 10 seconds
|
|
|
|
dhPutValue(document, ".Saved = %b", True)
|
|
dhCallMethod(document, "Close(%b)", False)
|
|
dhCallMethod(wordApp, "Quit")
|
|
|
|
SAFE_RELEASE(wordApp)
|
|
SAFE_RELEASE(documents)
|
|
SAFE_RELEASE(document)
|
|
SAFE_RELEASE(content)
|
|
SAFE_RELEASE(paragraphs)
|
|
SAFE_RELEASE(paragraph)
|
|
SAFE_RELEASE(rnge)
|
|
|
|
OleUninitialize()
|
|
dhUninitialize(True)
|