Sunday, September 20, 2009

Creating Notes Documents from Excel Sheet in lotusscript


Sub Initialize
Dim lspath,lsextn As String
Dim gosession As New NotesSession
Set godb=gosession.CurrentDatabase
Set godoc=New notesDocument(godb)

'Enter the Path and the XL file that has to be Imported into th
database..like the one is shown below

lspath=Inputbox$("Enter the Excel file path for importing into
the Notes Database")

lsxlFilename=lspath

'Create an Excel sheet object

Set gvExcel=CreateObject("Excel.Application")
gvExcel.visible=False

Messagebox ("Opening Excel sheet File eneterd in Input box
previously ...")
gvExcel.Workbooks.Open lsxlFilename
Set gvxlWorkbook=gvExcel.ActiveWorkbook
Set gvxlsheet=gvxlWorkbook.Activesheet

'Start to move through the Excel file and start pulling data
from there
lsrow=0
lswritten=0

'Start Importing into the Notes Database
Print "Start impoting from Excel sheet"

Do While True

With gvxlsheet
lsrow=lsrow+1

'Create a new Notes document

Set godoc=godb.CreateDocument
godoc.Form="TestForm"
godoc.Name=.Cells(lsrow,1).Value
godoc.Division=.Cells(lsrow,2).Value
godoc.Manager=.Cells(lsrow,3).Value

'Save the Notes document
Call godoc.Save(True,True)

lswritten=lswritten+1
If godoc.Name(0)="" Then
End
End If
End With

Loop
Set godoc=Nothing
gvExcel.quit

Goto CleanUp

CleanUp:
Exit Sub

ErrorHandler:
Msgbox "An error has occurred in the agImport at line no. " &
Erl() & " and the error is " & Str$(Err) & " " & Error$
Resume CleanUp

End Sub

1 comment:

  1. I know a lot of good programs and one of them pleased me. It to my surprise decided all my old problems with damaged excel files. Perhaps it will help in similar conditions, for example in this - recover Excel.

    ReplyDelete

Search This Blog