Manage Learn to apply best practices and optimize your operations.

Export to Word Script

A short routine to export to Word script

Although a lot of times I've found ways to export to Excel, I got frustrated trying to find a clean way to export to Word. So, I coded a short routine and came up with the following code which, although brief, does the job of exporting to Word.

Note: If the file to which you are exporting has some text, this will be pushed and the new text will be added before the existent text.

Dim ntNotes As NotesDocument     
Dim path As Variant
REM You should have a document in the dir temp of the
REM C drive named wordexp.doc or
REM whatever name you wish to call it.
Dim dbNotes As NotesDatabase
Dim ssNotes As New NotesSession
Dim vwNotes As NotesView
Set dbNotes = ssNotes.CurrentDatabase
REM make sure you change "viewName" by 
REM the actual name of the view you 
REM wish to import from
Set vwNotes = dbNotes.Getview ("viewName")
Set ntNotes = vwNotes.GetFirstDocument
Do While Not (ntNotes Is Nothing)
   REM set field values
   REM Get the Word object from a file.
   Set wordObj = GetObject(path)
   REM Get value of field from Notes fld
   REM Set Field value and a add a 
   REM carriage return at the end
   Call WordObj.ActiveWindow.Selection.TypeText  
   REM Save document	
   REM Clean from memory
   Set wordObj = Nothing			
   Set ntNotes = vwNotes.GetNextDocument(ntNotes)
   Set wordObj = Nothing		
   Msgbox "File has been exported to -->: " + path

Note- if the file to which you are exporting has some text, this will be pushed down and the new text will be added before the existent text. Also this traverses the named view and adds all the text into the word file, if you wish you could create separate word files for each notes document depending on a field value. If you need help drop me a line at

Dig Deeper on Lotus Notes Domino Agents

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.



  • iSeries tutorials's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...