About This Code
Brief Description:
Export to Word (Lotus Script)
Contributor:
Ted (ewizard2) Ford
Document Release:
Tested in 6.5.4 and 5.13a
Notes Version:
R5.x, R6.x
Last Modified:
21 Dec 2005
OpenNTF Disclaimer
All of the program code and information presented in the OpenNTF.org Code Bin are provided "as-is", and should be used at your own risk. OpenNTF.org make no express or implied warranty about anything in the Code Bin, and OpenNTF.org will not be responsible or liable for any damage caused by the use or misuse of anything from this site. OpenNTF.org makes no guarantees about anything. Please thoroughly test all of the knowledge and code you find here before you attempt to use them in your production environment.
Code / Description
This script will export domino Data using lotus script to microsoft word. This example will retrieve notes.ini variables and send them to ms word and saves the file as text file.
On line wordobj.ActiveDocument.SaveAs "c:\stagingr6\notes.ini",2
The 2 will save the file as text format. You can use the below numbers to save the file to a different format.
wdFormatDocument 0
wdFormatDOSText 4
wdFormatDOSTextLineBreaks 5
wdFormatEncodedText 7
wdFormatFilteredHTML 10
wdFormatHTML 8
wdFormatRTF 6
wdFormatTemplate 1
wdFormatText 2
wdFormatTextLineBreaks 3
wdFormatUnicodeText 7
wdFormatWebArchive 9
wdFormatXML 11
Usage / Example
'to prevent error for directory already created with mkdir line
On Error Resume Next
' Initialize variables
Dim session As NotesSession
Dim curdb As NotesDatabase
Dim ClientDataPath As String
Dim IdFileOnClient As String
Dim idFileNewOnClient As String
Dim ClientLocationDoc As String
Dim ClientMailSrv As String
Dim ClientMailFile As String
Dim wordobj As Variant
'Get session and database
Set session = New NotesSession
Set curdb = session.CurrentDatabase
' Get Client notes.ini information
ClientLocationDoc = session.GetEnvironmentString("Location",True)
ClientMailSrv = session.GetEnvironmentString("MailServer",True)
ClientMailFile = session.GetEnvironmentString("MailFile",True)
ClientDataPath = session.GetEnvironmentString("Directory",True)
IdFileOnClient = session.GetEnvironmentString("KeyFilename",True)
If Instr(idFileOnClient,"\")<>0 Then
IdFileNewOnClient = Strrightback(IdFileOnClient,"\")
Else
idFileNewOnClient = IdFileOnClient
End If
'Get hangle of word object
Set wordobj = CreateObject ("Word.Application")
' open document and show application
wordobj.Documents.Add
wordobj.Visible = True
wordobj.Activate
' Add text to ms word
wordobj.selection.TypeText "[Notes]" & Chr(10)
wordobj.selection.TypeText "KitType=1" & Chr(10)
wordobj.selection.TypeText "SharedDataDirectory=C:\Documents and Settings\All Users\Application Data\Lotus\Notes\Data\Shared" & Chr(10)
wordobj.selection.TypeText "SharedDataDirectory=C:\Documents and Settings\%username%\Application Data\Lotus\Notes\Data\Shared" & Chr(10)
wordobj.selection.TypeText "MailServer=" & ClientMailSrv &Chr(10)
wordobj.selection.TypeText "MailFile=" & ClientMailFile & Chr(10)
wordobj.selection.TypeText "Location=" & ClientLocationDoc & Chr(10)
wordobj.selection.TypeText "StackedIcons=1" & Chr(10)
wordobj.selection.TypeText "TCPIP=TCP,0,15,0" & Chr(10)
wordobj.selection.TypeText "Ports=TCPIP" & Chr(10)
wordobj.selection.TypeText "KeyFileName = " & Chr(10)
wordobj.selection.TypeText "TemplateSetup=600400" & Chr(10)
wordobj.selection.TypeText "Setup=650200" & Chr(10)
' Make directory on pc
Mkdir "c:\stagingr6"
' Save file as notes.ini in text format
wordobj.ActiveDocument.SaveAs "c:\stagingr6\notes.ini", 2
' Close word
wordobj.Quit
End Sub