//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "CreateOleObj.h"
#include "ComObj.hpp"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TMyForm *MyForm;
//---------------------------------------------------------------------------
__fastcall TMyForm::TMyForm(TComponent* Owner)
	: TForm(Owner)
{
}
//---------------------------------------------------------------------------
// BeginExample: CreateOleObject
// Routine: ComObj.CreateOleObject
// Routine: OleAuto.CreateOleObject

//BeginCode
/*
The following code shows an example of how to create an Ole Object and how to
perform specific operations.
*/
void __fastcall TMyForm::ButtonClick(TObject *Sender)
{
	OleVariant WordApp, NewDoc;

	/* Creates a Microsoft Word application. */
	WordApp = CreateOleObject("Word.Application");

	/* Creates a new Microsoft Word document. */
	NewDoc = WordApp.OlePropertyGet("Documents").OleFunction("Add");

	/* Inserts the text 'Hello World!' in the document. */
	WordApp.OlePropertyGet("Selection").OleFunction("TypeText", "Hello World!");

	/* Saves the document on the disk. */
	NewDoc.OleFunction("SaveAs", "my_new_document.doc");

	/* Closes Microsoft Word. */
	WordApp.OleFunction("Quit");

	/* Releases the interface by assigning the Unassigned constant to the Variant variables. */
	NewDoc = Unassigned;
	WordApp = Unassigned;
}
//EndCode
//EndExample: CreateOleObject
//---------------------------------------------------------------------------
