18.01.2013 Views

LotusScript for Visual Basic Programmers - IBM Redbooks

LotusScript for Visual Basic Programmers - IBM Redbooks

LotusScript for Visual Basic Programmers - IBM Redbooks

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

In <strong>Visual</strong> <strong>Basic</strong>, we can access the Notes objects in one of two ways:<br />

Directly, if the object can be created externally.<br />

Indirectly, if the object is a dependent object. You can get a reference to<br />

it from another object higher in the Notes class hierarchy.<br />

NotesSession and NotesUIWorkspace are object classes that can be created<br />

externally. We can access these two classes directly from <strong>Visual</strong> <strong>Basic</strong> using<br />

the CreateObject function. NotesSession and NotesUIWorkspace are at the<br />

highest level of the hierarchy. Other object classes are dependent object<br />

classes, and can be accessed only by using a method or a property of one of<br />

the two classes.<br />

In our previous example, Create Document, we created the externally<br />

creatable object session first. Then we used a method of the session type<br />

object to access the lower-level class db.<br />

Let’s look at some examples:<br />

Example<br />

This example accesses the current document in Notes Workspace.<br />

Dim workspace As Object<br />

Dim UIdoc as Object<br />

set workspace = CreateObject ("Notes.NotesUIWorkspace")<br />

set UIdoc = workspace.CurrentDocument()<br />

To access the current document (NotesUIDocument object) in <strong>Visual</strong> <strong>Basic</strong>,<br />

we first need to get a reference from NotesUIWorkspace. Then we use the<br />

CurrentDocument property of the NotesUIWorkspace class to get the<br />

reference to the NotesUIDocument class. We declare workspace as an object<br />

which references NotesUIWorkspace. We declare UIdoc as an object which<br />

references NotesUIDocument.<br />

Dim workspace As Object<br />

Dim UIdoc As Object<br />

Create an externally creatable object.<br />

set workspace = CreateObject ("Notes.NotesUIWorkspace")<br />

Use the externally creatable object to access a lower-level object doc.<br />

set UIdoc = workspace.CurrentDocument()<br />

92 <strong>LotusScript</strong> <strong>for</strong> <strong>Visual</strong> <strong>Basic</strong> <strong>Programmers</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!