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.

Converting a HiTest Application Using Notes Classes in <strong>Visual</strong> <strong>Basic</strong><br />

through OLE Automation<br />

Lotus Notes Release 4 is an OLE automation server. Converting your<br />

HiTest applications to <strong>LotusScript</strong> Notes classes through OLE automation<br />

enables you to develop and use your applications in all the environments<br />

supported by <strong>Visual</strong> <strong>Basic</strong>, such as Windows, Windows 95 and Windows<br />

NT.<br />

To convert applications developed using the HiTest tools, you translate the<br />

HiTest <strong>Basic</strong> API functions to equivalent Lotus Notes functions. There is a<br />

number of <strong>LotusScript</strong> Notes class methods that per<strong>for</strong>m functions<br />

equivalent to HiTest functions.<br />

Note For more details, see Appendix 1.<br />

By converting your HiTest applications, you can more easily access the new<br />

Release 4 Notes design elements. For example, HiTest has no support <strong>for</strong><br />

accessing the current Notes document and Notes item. <strong>LotusScript</strong> Notes<br />

classes, on the other hand, include NotesUIWorkspace and<br />

NotesUIDocument which enable you to access the current Notes workspace<br />

and the current Notes document. You can access the current Notes item<br />

using the CurrentField property of NotesUIDocument.<br />

Let’s look at an example.<br />

Example<br />

This example shows how you can access the current Notes document in<br />

<strong>Visual</strong> <strong>Basic</strong> using <strong>LotusScript</strong> Notes classes through OLE automation. You<br />

will need to keep both Lotus Notes and the current document open.<br />

Otherwise, although the application will be able to open the Notes<br />

workspace, it will return an error message indicating that it cannot find the<br />

current document.<br />

Dim uispace As Object<br />

Dim uidoc As Object<br />

Dim doc As Object<br />

Set uispace = CreateObject("Notes.NotesUIWorkspace")<br />

Set uidoc = uispace.CurrentDocument<br />

Set doc = uidoc.Document<br />

Print (doc.Created)<br />

Set uispace = Nothing<br />

To get the Subject item value of the current document (NotesUIDocument),<br />

we need to get the hierarchy from the current workspace<br />

Chapter 5: Converting HiTest Applications 103

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

Saved successfully!

Ooh no, something went wrong!