I have a domino database in which all docs will be deleted. I need to create new docs and on each document attach either a word or excel document. There are a total of 700 word/excel docs that will have to be attached, therefore 700 notes documents that will have to be created. How can I automatically do this?
This code is NOT complete... It is mostly functional, but it is meant to demonstrate how you could complete the task you are attempting. You will have to fill in some blanks yourself.
First, use the method in the following example to build an array of filenames for your program...
Dim pathName1, pathName2, fileName1, fileName2 As String PathName1 = "c:\*.xls" FileName1 = Dir$(pathName1, 0) PathName2 = "c:\*.doc" FileName2 = Dir$(pathName2, 0) Dim counter as integer Do While fileName1 <> "" Redim preserve fileList1(counter) FileList1(counter) = FileName1 FileName1 = Dir$() 'Repeat for FileName2... Counter = counter + 1 Loop Dim thisNotesDB as NotesDatabase 'Set it with NotesSession, etc... For k = 0 to ubound(FileName1) Dim newDoc as New NotesDocument(thisNotesDB) Dim object as NotesEmbeddedObject Dim item as NotesRichTextItem Set item = new NotesRichTextItem( newDoc, "body" ) Set object = item.EmbedObject( EMBED_ATTACHMENT, "", filename1(k)) Call newDoc.save( false, false ) Next k
This was first published in December 2001