Automating Write

As an example, let's assume Write needs to be started from another application (e.g. Spreadsheet – but it could be any application that supports OLE automation) and a you want to create and print some text. Here's the code:

Set app = CreateObject("AbilityWrite.Application")

app.Activate

Set mydoc = app.Documents.Add("NORMAL")

myDoc.Text.Insert 0, "This is a simple document"

myDoc.Print 0, 99, 1, False

The second line "app.Activate" causes the application to become visible to the user (otherwise the application would run in the background and not be visible). Next, a new document is created, based on the normal template, and a reference to the document is saved in a variable mydoc.

The rest of the macro adds text to a document and prints it.

Note: The Print function takes four parameters: start page, end page, number of copies and "collate" (or not).