Manage Learn to apply best practices and optimize your operations.

Opening And Viewing A Notes Database From Visual Basic

Have you ever wanted to open and view a Notes Database directly from a Visual
Basic Application? The problem many people run into is they are unable to
force the Notes Application into the Foreground for the user to view. With this
tip, the Notes Application will always open in the foreground with the database
of your choice opened for viewing.
'First you will need to define a Windows API in the declarations section your
VB Project

Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
(ByVal hWnd As Long, ByVal lpOperation As String, ByVal lpFile As String, _
ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As
Long) As Long

'Now from the click event of a Button on a Visual Basic Form, add the following
code.

dim session as Object
dim uiWs as Object
dim dbName as string
dim serverName as string
dim iRet as integer

dbName = "cipher\cipher.nsf" 'The value of this should match the name of the
database you want to open
serverName = "rtpswgs6" 'The server where your database resides

'First Create an Instance of the Session Object. If the Notes Interface is
already running this simply passes focus to it. If the interface is not
running it will start Lotus Notes

set session = CreateObject("Notes.NotesSession")

'Second Make a Call to the Windows API that we defined in the declarations
section. This is the key to the tip. By making a call to this function you
are ensuring that Lotus Notes Moves to the Foreground so the user is guaranteed
to see it.

iRet = ShellExecute(Me.hWnd, "Open", "notes.exe", vbNullString, dummyString,
SW_SHOWNORMAL)


'Now we create an instace of the NotesUIWorkSpace object so that we can open
our database for the user to view and look at

set uiWs = CreateObject("Notes.NotesUIWorkSpace")

'Make a call to the OpenDatabase method to open the database of your choice

call OpenDatabase(serverName, dbName) 'This will open the database to the view
last viewed by the user

'call OpenDatabase(serverName, dbName, "viewName") 'will Opnen the database to
the view that you want them to see.

Dig Deeper on Domino Resources - Part 7

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchWindowsServer

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchDataCenter

SearchContentManagement

Close