lathan reddy 17.Aug.12 11:47 AM a Web browser Domino Designer7.0.1Windows XP
I need to import the data from excel file.
In the Excel file I have around 15 columns, but I wanted two to import only 3 Columns (Column B, Column J, and Column N) columns data needs to be import, that I did without any issues.
Code Below Mentioned:
Dim session As New NotesSession
Dim wks As New NotesUIWorkspace
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim row As Integer
Dim written As Integer
Dim xFilename As Variant
Set db = session.CurrentDatabase
xFileName = wks.OpenFileDialog(False,"Select an excel file to import.","Microsoft Office Excel Workbook|*.xls","C:\")
If Isempty(xFileName) Then
Msgbox "You have cancelled the import process.",64,"Import Cancelled"
Else
Msgbox "Starting import from file " + xFileName(0),64,"Initiating Import"
Dim Excel As Variant
Dim xlWorkbook As Variant
Dim xlSheet As Variant
Print "Connecting to Excel..."
Set Excel = CreateObject("Excel.application")
Excel.Visible = False
Set xlWorkbook = Excel.Workbooks.Open(xFileName)
Set xlWorkbook = Excel.ActiveWorkbook
Set xlsheet=xlWorkbook.ActiveSheet
Print "Starting import from Excel file..."
Dim NumberOfRows As Long
NumberOfRows = xlSheet.UsedRange.Rows.Count
row =0
written =0
row = row +1
Set doc = db.CreateDocument
Set doc = Nothing
For row =8 To NumberOfRows
With xlSheet
Set doc = db.CreateDocument
doc.Form = "Employee"
Call doc.ComputeWithForm(False,False)
doc.EmployeeID= .Cells(row,2).Value
doc.EContact= .Cells(row,14).Value
doc.EDesig= .Cells(row,10).Value
Call doc.save(True,True)
written = written + 1
row = row + 0
If row = NumberOfRows +1 Then
Goto Done
Else
End If
Print written & "records imported..."
End With
Next
Done:
Print "Disconecting from Excel..."
xlWorkBook.close False
Excel.quit
Set Excel = Nothing
Print " "
End If
Exit Sub
Here my problem is if they modify the columns in excel sheet weekly or monthly or if they delete the column A, then that case all rest of the column order will change right? For example: Earlier it was Column D now it is Column C (Because, Column A Is deleted from the excel sheet due to that reason other column order will be change).
Is there any way to provide the permission to the user (is there any way to prompt message to the end user to import correct data with mismatch (or) is there any configuration settings we can do?) if the user change the Column H to Column Y then that case column Y Data needs to be import form excel sheet to lotus notes database view.
please help me some one to do the above functionality.Thanks!!