I need Visual Basic code to scroll to a document in notes.

I need VB code (if possible, if not, then I'll try and decypher notes script) to navigate within notes and select a certain document within a CATEGORIZED view.

If I use:
objNotesws.OpenDatabase "server", "database", "view", "document"
then it takes me to the title of that document.  I need to drill down and actually select the relevant document, so that the user can then open the document within notes.
I need:
      >Title 3.
But I get:
I hope this makes sense.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

u want a categorized view to appear in a VB prog and the user to be able to choose any document and get it displayed in notes? is that it?
deljonesAuthor Commented:
Not quite.  I've got some Oracle tables from which I get some information that is also stored on a notes database.  Then in my vb prog, the user selects a record, then I want to switch to notes, to the relevant document in the notes view.  Then they can do what they want with this docuement in notes.  The problem is, that because the view in notes is categorised, the record selected when I open the view (with OpenDatabase) is the very high level 'title' rather than the actual document I want.

ok u mean the parent document is the one that is getting selected, and u want the VB prog to open the view in notes with the right child document selected.  I will see about that.
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

Notes will always locate documents based on the first sorted column in a view.  Since the first one is the categorized view, Notes will stop there in the first category that contains the document even within nested categories. I suggest the following work around.  Instead of Notes drilling down to the document, open the document for the users. Check this snippet of code:

Public session As NOTESSESSION
Public view As NOTESVIEW
Public testvar As Variant

Private Sub Command1_Click()
   Set session = CreateObject("Notes.NotesSession")
   Set db = session.GETDATABASE("", "test.nsf")
   Set ws = CreateObject("Notes.NOTESUIWORKSPACE")
   Call ws.OPENDATABASE("", "test.nsf", "test", "Kenan")
   Set view = db.GETVIEW("test")
   Set doc = view.GETFIRSTDOCUMENT
   Do While Not (doc Is Nothing)
      testvar = doc.GETITEMVALUE("name")
      If testvar(0) = "Kenan" Then Exit Do
      Set doc = view.GETNEXTDOCUMENT(doc)

   Call ws.EDITDOCUMENT(False, doc)
   Set doc = Nothing
   Set view = Nothing
   Set db = Nothing
   Set session = Nothing
End Sub

Modify this to ur own needs. u have to put a field as a serach criteria to look for a specific doc.
deljonesAuthor Commented:
Thanks for your answer ghassan99,
I already have code to do this via an uncategorised view:

Set sess = CreateObject("notes.notessession")
Set db = sess.getdatabase("server", "database")
Set view = db.getView("UncategorisedView")
set doc = view.getdocumentbykey
ws.editdocument false, doc

But I really need to navigate to the document in a categorised view.

Is there a way of executing lotus @commands in visual basic?

I truly believe its not possible, I tried creating a hidden view, but it will affect the categorization.  Notes will just encounter the categories first since they are the first sorted column.  
A lookup in a categorized view - should be the same as an uncategorized.
If you use a key like "Title1\Title2\Title3" you should try replacing code with this:

Dim key(1 To 3) As String
Set doc = view.GetDocumentByKey( key )
deljonesAuthor Commented:
This code will only work with the back-end navigation.  I can find the document I want via an uncategorised view, but I can't navigate to it and highlight it with this categorised view on the UI.  I think the only way you can actually highlight a document in a view is with the

OpenDatabase server, database, view, key

command, but as I say, this only takes me to the category, rather than the actual document.  I tried putting an array on the key bit of the command, but that didn't work either.
yes, the opendatabase method is the only way available, coz looking up keys is based on a sorted column.  Gunsen's proposal will just move u closer to the category.  No solution for this:)
Sorry I didn't read through all the previous post, perhaps someone already went this way ...

After having found the document, you could put the DocUniqueID of the document in a profile document within the database of in an environment variable and then call an agent that will select the document.

The agent will fetch the DocumentUniqueID and then perform a SELECT on the UNIQUEID


UNID := @Environment("$TheDocIwantSelected")
SELECT @IsMember(UNID;@DocumentUniqueID)


anyway, I suspect to have an error in my code up there (wich parameter the @IsMember uses) and I don't know if the category will be open ...

At worse, and once the document is selected, you can alway call @Command([ViewShowOnlySelected]) followed by a @Command([ViewExpandAll]) or something like that ... that will make only the selected document appear ...

If it solves your problem, I'll post this as an answer.

For a NotesR4.6 client You could use the NotesUIView class - SelectDocument method.
Trigged by QueryOpen-event you could use following code:

Sub Queryopen(Source As Notesuiview, Continue As Variant)
Dim workspace As New NotesUIWorkspace
Dim session As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim key(1 To 3) As String
key(1)=session.GetEnvironmentString( "MyTitle1" )
key(2)=session.GetEnvironmentString( "MyTitle2" )
key(3)=session.GetEnvironmentString( "MyTitle3" )

If key(1)<>"" Then
  Set db = session.CurrentDatabase
  Set view = db.GetView("View")
  Set doc = view.GetDocumentbykey(key)
  Call Source.SelectDocument(doc)
  Call session.SetEnvironmentVar( "MyTitle1", "" )
End If

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Lotus IBM

From novice to tech pro — start learning today.