Domino Code Fragment

Code Name*
Word Doc Create
Date*
03/19/1999
Source (or email address if you prefer)*
Mackie
IP address:.3.144.109.5
Description*
Creates a MSWord doc with header block from Notes field data
Type*
LotusScript
Categories*
OLE/ActiveX Integration
Implementation:
Modify code
Required Client:
4.5
Server:
(none)
Limitations:
Comments:
Useful in Contact type databases to create letters etc
Files/Graphics attachments (if applicable): Code:
Sub Click(Source As Button)
     Dim wordobj As Variant
     Dim add As String
     
     ' this code uses many of the Wordbasic commands in Word 97
     'set up the word document

     Set wordobj = CreateObject("Word.Basic.8")
     
     'get the Address, Salutation , lastname and fullname fields    from    the current document

     Dim workspace As New NotesUIWorkspace
     Dim uidoc As NotesUIDocument
     Set uidoc = workspace.CurrentDocument
     add=uidoc.FieldGetText( "MailAddress" )
     sal=uidoc.FieldGetText( "Salutation" )
     LastName=uidoc.FieldGetText( "LastName" )
     FullName=uidoc.FieldGetText( "FullName" )
     
     
     
     If WordObj Is Nothing Then
          Msgbox "There was a problem loading MS Word."
          Exit Sub
     End If
     
     ' create new doc in MS Word
     WordObj.filenew  
     
     
     
     wordobj.font "Univers"
     wordobj.fontsize 11
     
     wordobj.insertpara
     wordobj.insertpara
     wordobj.insertpara
     wordobj.insertpara
     wordobj.insertpara
     
     ' time format i.e 5 Febuary, 1999
     DateTimeFormat="d MMMM, yyyy"
     
     ' inset the text and the field values
     wordobj.insert "Our Ref:"
     wordobj.insertpara
     wordobj.insert "Your Ref:"
     wordobj.insertpara
     wordobj.insert "IPC:"
     wordobj.insertpara
     wordobj.insertpara
     wordobj.insertpara
     
     
     wordobj.insert "Date:"
     
     wordobj.InsertDateTime    DateTimeFormat
     wordobj.insertpara
     wordobj.insertpara
     wordobj.insertpara
     wordobj.underline
     wordobj.insert "For the attention of : "
     wordobj.insert Fullname
     wordobj.underline
     wordobj.insertpara
     wordobj.insertpara
     
     wordobj.insert add
     wordobj.insertpara
     wordobj.insertpara
     wordobj.insertpara
     
     wordobj.insert "Dear  " & Sal &  "  " & Lastname
     wordobj.insertpara
     wordobj.insertpara
     
     wordobj.insert "Subject:"
     wordobj.insertpara
     wordobj.insertpara
     
     
     ' display MS Word
     WordObj.AppShow
     
End Sub