Hi there,
i have an excel sheet with only the first column populated with some value (windows file path) that i want to import into a text field in a database. I want to go as far as the 1465th row.
I created an agent with the following code. At first the code ran but it did not populate the values from excel file - strangely it seems to have copied the value of another field within the document. Some of the cells are blank (no file path specified) - so it showed ‘None listed’ there - which again seems to be a value taken from another field in the same document. It appears as though it filled these values after it failed to get them from excel file.
Now when i tried to run the same code (no changes made), i get ‘type mismatch’ error … since this is a test database, i deleted all the documents and then copied them again from the parent database - still get the error.
Thanks for all your help!
Ayaz
Sub Initialize
Dim s As New NotesSession
Dim ws As New NotesUIWorkspace
Dim db As NotesDatabase
Dim view As NotesView
Dim doc As NotesDocument
Dim row As Integer
Dim xlFileName As Variant
Dim Excel As Variant
Dim xlWorkBook As Variant
Dim xlSheet As Variant
Dim xlCell As Variant
Set db = s.CurrentDatabase
xlFileName = "C:\Documents and Settings\abcd\parts.xls"
Set Excel = createObject("excel.Application")
Excel.visible = False
Excel.workbooks.open xlFileName
Set xlWorkBook = Excel.ActiveWorkBook
Set xlSheet = xlWorkBook.ActiveSheet
Set xlCell = xlSheet.cells
Set view = db.getview("<view name>")
Set doc = view.GetFirstDocument
row=1
Do While Not (doc Is Nothing)
doc.<field name> = xlCell(row,1).value
Call doc.Save( True, True )
Set doc = view.GetNextDocument(doc)
row=row+1
If row > 1465 Then Exit Do
Loop
Excel.Quit
End Sub