Hi all,
I have come across some code that a previous programmer had written to export selected documents in view. The problem I am having is that the code generates an eror message that says: “Object variable is not set” for the line that says:“carray= view.Columns”.
Can someone tell me why this is coming up? Is this a syntax thing? How can this be fixed?
Thanks,
Dan
Declarations:
Type PersonRecord
FirstName As String * 30
LastName As String * 50
Title As String * 10
Promotion As String * 50
AccountNumber As String * 50
Address As String * 30
Parish As String * 30
PostalCode As String * 10
HomePhone As String * 15
WorkPhone As String * 15
CellularPhone As String * 15
FaxNumber As String * 15
PagerNumber As String * 15
EMailAddress As String * 50
End Type
Sub Initialize
'--Declarations
'--Initialise Variables
Print "Initialising..."
Dim s As New notessession
Dim db As notesdatabase
Dim doc As notesdocument
Dim view As notesview
Dim coll As notesdocumentcollection
'file stuff
Dim fileNum As Integer
Dim fileName As String
Dim rec As PersonRecord
fileNum% = Freefile()
fileName$ = "c:\DATA1.TXT"
Set db=s.CurrentDatabase
Print "Opening Views..."
Set view=db.GetView("vMailMerge")
Set coll=db.unprocesseddocuments
num=coll.count
carray= view.Columns
numcols=Ubound(carray)+1
For c =Lbound(carray) To Ubound(carray)
If c=0 Then
columnstring=carray(c).title
Else
columnstring=columnstring & "%" & carray(c).title
End If
Next
columnstring=columnstring & "#"
'Msgbox columnstring
' First, open a random file with a record length equal to
’ the size of the records to be stored.
Print "Creating Text File..."
Open fileName$ For Output As fileNum%
counter% = 1
'--loop thru
'For i = 1 To num
Write #fileNum%, columnstring
’ Set doc=coll.GetNthDocument(i)
Set doc = view.GetFirstDocument
While Not ( doc Is Nothing )
’ Print “Getting Member…” & counter% & " of " & num
' If doc Is Nothing Then
' Write #fileNum%, notesname,"+++Person Document Not Found+++"
’ Else
REM Msgbox pdoc.Shortname(0)
For d =Lbound(carray) To Ubound(carray)
If d=0 Then
columnvals=doc.ColumnValues( d)
Else
columnvals=columnvals & "%" & doc.ColumnValues( d)
End If
Next
'Msgbox columnvals
columnvals=columnvals & "#"
Write #fileNum%, columnvals
' End If
’ Next i
Set doc = view.GetNextDocument( doc )
counter% = counter% + 1
Wend
Print "Closing Text File..."
Close fileNum% ' Close the file.
Print "Done."
End Sub