Hi All,I need your assistance. I have the code below that imports data from an excel spreadsheet to a lotus notes database which is working OK. However if the row in excel is blank, it removes the current data from the lotus database field. How can I modify the code that if any of the rows specified in the code is blank then ignore and leave the current data in the lotus notes database field.
Thanks
Sub Initialize
Dim xlFilename As String
xlFilename = Inputbox$("Enter the Complete Path of the Excel File to be imported", "Excel Import" , "c:\test.xls")
Dim session As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim doc As NotesDocument
Dim s_key As String
Dim row As Integer
Dim written As Integer
Dim Excel As Variant
Dim xlWorkbook As Variant
Dim xlSheet As Variant
Set db = session.CurrentDatabase
Set view = db.getview("All Docs")
Print "Connecting to Excel..."
Set Excel = CreateObject( "Excel.Application" )
Excel.Visible = False
Print "Opening " & xlFilename & "..."
Excel.Workbooks.Open xlFilename
Set xlWorkbook = Excel.ActiveWorkbook
'Set xlSheet = xlWorkbook.ActiveSheet
Set xlSheet = xlWorkbook.worksheets("Sales_Data")
Records:
row = 1 '// These integers intialize to zero anyway
written = 0
Print "Starting import from Excel file..."
While xlsheet.cells(row,1).value <> ""
Finish:
With xlSheet
Set doc = view.getdocumentbykey(Trim(.Cells(row, 1).Value))
If Not doc Is Nothing Then
doc.SalesDate = Trim(.Cells( row, 2).Value)
doc.ProductDate=Trim( .Cells(row, 3).Value)
doc. SalespersonTrim( .Cells(row, 4).Value)
Call doc.Save( False, True )
End If
row = row + 1
Print row
End With
Wend
Done:
Print "Disconnecting from Excel..."
xlWorkbook.Close False
Excel.Quit
Set Excel = Nothing
End Sub