I’m trying to import excel file into notes db with the following script: Can someone please tell me what is wrong with the code.
Sub Initialize
On Error Goto ErrorHandler
Dim session As New NotesSession
Dim db As Notesdatabase
Dim FormName As String
Set db = session.CurrentDatabase
Dim CurrentTime As String
Dim MBTitle As String
MBTitle = "Trying to Import File"
ImportFile = "" ' Name of the File
Title = "Select File"
Filter = "All Files|*.*|"
ErrorStatus=False
Do
If NEMGetFile( 0, ImportFile, Filter, Title) <> 0 Then
location=ImportFile
If Dir$(location, 0) =“” Then
ErrorStatus=False
Else
ExcelFile = Location
End If
Else
retval2=Msgbox( “You have not selected the location of the Import File. Do you want to exit ?”,4+256,“ABORT”)
If retval2=7 Then
ErrorStatus=True
Else
Exit Sub
End If
End If
Loop Until ErrorStatus=False
Dim DownloadDoc As notesdocument
Print “Searching for the Excel file”
Set xls = GetObject(ExcelFile,“”)
Dim tmpdoc As notesdocument
Set tmpDoc = db.CreateDocument
tmpdoc.ExcelFile = ExcelFile
Const FileName$ = “@RightBack(ExcelFile ;”“\”“)”
EXFile = Evaluate(FileName$,tmpdoc)
Print “Processing the Excel file”
If Ucase$(EXFile(0)) = “UpdateUsers.xls” Then
’ Create User Profile
FormName = “UP”
currentTime = Time$()
Forall sheet In xls.Worksheets
For i = min To max
B = Trim(sheet.range(“B” & i).value)
If B =“” Then
If i = min Then
’ If Row 2, Column 2 is missing
msgdesc = “No Values to Retrieve” + Cstr(i)
Msgbox msgdesc,48,MBTitle
Exit Sub
End If
Else
’ Creating a New Order Document
Do
'This will Loop until the time is changed by atleast one second
If CurrentTime <> Time$() Then
currentTime = Time$()
Exit Do
End If
Loop
Set DownLoadDoc = db.CreateDocument
If FormName = “UP” Then
DownLoadDoc.form = FormName
DownLoadDoc.UP_GeoLocation = Trim(sheet.range(“A” & i).value)
DownLoadDoc.UP_UserRole = Trim(sheet.range(“B” & i).value)
DownLoadDoc.UP_NotesID = Trim(sheet.range(“C”& i).value)
DownLoadDoc.UP_EmailAddress = Trim(sheet.range(“D” & i).value)
Call DownLoadDoc.ComputeWithForm(True, True)
Call DownLoadDoc.Save(True, True)
End If
End If
Next
Exit Forall
End Forall
Print “Disconnecting from Excel…”
Set xls = Nothing '// Free the memory that we’d used
Print "Import has finished. "
msgdesc = "Sample Import has Finished from " + EXFile(0)
Msgbox msgdesc,48,MBTitle
Print " " '// Clear the status line
Exit Sub
ErrorHandler:
Messagebox “Error” & Str(Err) & ": " & Error$
Exit Sub
End If
End Sub