Subscript out of range 44 error 9

Hi I have the an agent that prints out a view in Excel on Web and for some reason it exports the first column and then fails on the second column with the subscript out of range 44 error number 9. I have implemented the same code in another view with a different selection formula and it works fine there. I noticed that in the debugger the columnvalues are not coming in an array (0)(1)(2)(3)(4) like the other view where it works. I only get the first value (0). It has to be in the view but I can’t figure it out, I have deleted and created the view again but the error persists. It fails on the line noted below, here is the code:

Dim session As New NotesSession

Dim db As NotesDatabase

Dim excel As Variant

Dim worksheet As Variant

Dim cell As Variant

Dim view As NotesView

Dim nav As NotesViewNavigator

Dim entry As NotesViewEntry

Dim rowNum As Integer

Dim doc As notesdocument

On Error Goto ErrorHandler

'The content type of application/vnd.ms-excel tells the browser to use Excel.

'Then we simply build a table. The first row, we set the column widths and put the headers in bold.

Print {Content-Type:application/vnd.ms-excel}

Print {<HTML><HEAD>}

Print {</HEAD>}

Print {<BODY>}

Print {<TABLE>}

Print {<TR>}

Print {<TD WIDTH="80"><B>MONTH</B></TD>}

Print {<TD WIDTH="100"><B>DEPARTMENT</B></TD>}

Print {<TD WIDTH="160"><B>EMPLOYEE NAME</B></TD>}

Print {<TD WIDTH="100"><B>WEEK DATE </B></TD>}

Print {<TD WIDTH="120"><B>TOTAL HOURS</B></TD>}

Print {</TR>}



rowNum = 2 ' Current row of data

’ Get a NotesViewNavigator from our view

Set db = session.CurrentDatabase

Set view = db.GetView("GT45")

Set nav = view.CreateViewNav

Set entry = nav.GetFirst

’ Go through all the entries in the view

While Not entry Is Nothing 

	

	Print {<TR>}

	Print {<TD>} & Cstr(entry.ColumnValues(0)) & {</TD>}

	Print {<TD>} & Cstr(entry.ColumnValues(1)) & {</TD>} ' <--SUBSCRIPT OUT OF RANGE ERROR ON THIS LINE

	Print {<TD>} & Cstr(entry.ColumnValues(2)) & {</TD>}

	Print {<TD>} & Cstr(entry.ColumnValues(3)) & {</TD>}

	Print {<TD  bgcolor=#D3D3D3>} & Cstr(entry.ColumnValues(4)) & { </TD>}

	Print {</TR>}

	rowNum = rowNum + 1

	Set entry = nav.GetNextCategory(entry)

Wend







Print "</TABLE></BODY></HTML>"



Exit Sub

ErrorHandler:

Print "Problem Generating Report, Error Number = " & Err() &" Error Message = " & Error()  & " Error on line = " & Cstr(Erl())	



End Sub

Thanks,

Armand

Subject: RE: Subscript out of range 44 error 9

I think you are scanning a categorized view. Since you’re looking at all the row entries, your scan will also hit rows that contain only a category heading and no document. Such rows will not contain values for the other columns following the category.

I believe there’s an IsCategory property, or something like that, which you can use to distinguish them.

Subject: Subscript out of range 44 error 9

Hi,maybe the first column of your view is categorized. Then

Set entry = nav.GetFirst

returns row with the firts category in view and ubound of this entry’s columnvalues is 0.

Piotr