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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

The HiTest <strong>Visual</strong> <strong>Basic</strong> API does not support folders. If your application<br />

needs to access folders, you must use Notes classes through OLE<br />

Automation.<br />

Using Notes classes through OLE Automation in <strong>Visual</strong> <strong>Basic</strong>, you can<br />

access Notes folders the same way you access Notes views. All the methods<br />

that work with Notes views also work with Notes folders.<br />

Accessing Notes Views and Folders in <strong>LotusScript</strong><br />

Accessing Notes views and folders using <strong>LotusScript</strong> in Notes works the<br />

same way as accessing views and folders in <strong>Visual</strong> <strong>Basic</strong> using Notes classes<br />

through OLE Automation. However, you declare the variables referring to<br />

the view or folder as a Notes class rather than as an object.<br />

In this part of the chapter, we will discuss the New method of NotesView,<br />

which is new in Notes Release 4.5.<br />

When you access Notes views and folders in <strong>LotusScript</strong>, you can use the<br />

Forall and Foreach statements, which make your application more simple.<br />

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

Example<br />

This example accesses the view’s properties. You can put this sample code<br />

on a new agent in the TEST database. Then choose the initialize function to<br />

drive the script.<br />

Sub Initialized<br />

Dim session As New NotesSession<br />

Dim db As NotesDatabase<br />

Set db = session.CurrentDatabase<br />

REM view is a NotesView object<br />

REM cannot be Dim'd - loop reference variable<br />

Forall view In db.Views<br />

142 <strong>LotusScript</strong> <strong>for</strong> <strong>Visual</strong> <strong>Basic</strong> <strong>Programmers</strong><br />

Messagebox "View name: " & view.Name & Chr(10) _<br />

& "Parent: " & view.Parent.Title & Chr(10) _<br />

& "Last modified: " & view.LastModified & Chr(10) _<br />

& "Created: " & view.Created & Chr(10) _<br />

& "Universal ID: " & view.UniversalID<br />

If view.IsDefaultView Then _

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

Saved successfully!

Ooh no, something went wrong!