Object Varialbe not set

I tried to create a Agent for a Lotus Notes DB and I am getting Object Variable not set error.

Sub Initialize

Dim ws As New NotesUIWorkspace

Dim uiview As NotesUIView

Dim view As NotesView

Set uiview = ws.CurrentView

Set view = uiview.View     '********** LOTUS DBUGGER HIGHLIGHTS THIS CODE NO OBJECT VARIABLE NOT SET ERROR

Dim filenames As Variant	

Call  ViewExcelPrint   (view)	

End Sub

Subject: agent

How are you calling the agent? Via an action in a view? If not, then there is no current view of course, so that would explain it.

If you are running it via an action, might be worth just moving the code into the action, don’t see why this should be in an agent