view.GetFirstDocument

Hi,

I have a scheduled agent that creates an html file from data in a view. When I run it from the menu, it works fine, but on schedule I get Object Variable not set, just before Set doc=view.GetFirstDocument.

Sub Initialize()

 Dim session As New NotesSession 

 Dim db As NotesDatabase

 Dim HappeningView As NotesView

 Dim doc As NotesDocument 

 Dim HTMLPath As String

 Dim DisplayString As String

 Dim columnValue As String

 Dim fileName As String

 Dim fileNum As Double

 

 Dim universalID As String*32

 

 Dim NewsItemName As Variant

 Dim strNewsItemName As String

 

 Dim strTest As string

 

 'Set db = session.CurrentDatabase

 Set db = New NotesDatabase( "MyServer", "EventsCal.nsf" )





 On Error GoTo ErrorProc     

 fileNum = FreeFile()

 HTMLPath = "D:\Notes\data\domino\html\" 

 fileName = HTMLPath & "HappeningArray.html"

 Close fileNum

 Open fileName For Output As fileNum

 



     

 Set HappeningView = db.GetView ( "HappeningArray" )

 strTest = "Open view"

 Set doc = HappeningView.GetFirstDocument

 strTest = "set doc"

 Do While Not ( doc Is Nothing )     	

 	universalID = doc.UniversalID     

 	NewsItemName = doc.Getitemvalue("NewsItemName")

 	strNewsItemName = NewsItemName(0)

      'columnValue = doc.ColumnValues( 0 )   

      DisplayString =DisplayString & "{&quotid&quot:&quot" & universalID & "&quot,&quotname&quot:&quot" & strNewsItemName & "&quot}"     

      DisplayString = DisplayString & ","

      Set doc = HappeningView.GetNextDocument ( doc )

 Loop

 strTest = "complete test string"

 DisplayString = Left(DisplayString , Len(DisplayString)-1)

Print #fileNum, "[" & DisplayString & "]"



Close fileNum

Exit Sub



ErrorProc:

'Open fileName For Output As fileNum

Print #fileNum, "Error " & Err() & ": " & Error()   

Print #fileNum, strTest

Print #FileNum, fileName

Close fileNum



Exit Sub

End Sub

Subject: view not set?

to me would indicate the view is not getting set. perhaps the view is a personal view and not a shared view so the server cannot “see” it?

Subject: re: view.getfirstdocument

Is the output file created successfully when you run it as scheduled?