Sub NewWordDoc(msword As Variant, worddoc As Variant, IsVisible As Variant)
'msword and worddoc are for passing back control of the instance of word an the new word document respectively
'IsVisible is for determining whether on not to make the instance of Word visible
'Create an instance of Word
Set msword = CreateObject("Word.Application")
Set docs = msword.Documents
msword.Visible = IsVisible
'Create a new word document and set it to active
Call docs.Add
Set worddoc = docs(1)
worddoc.Activate
?Open an existing Word Document
Call msword.Documents.Open("""c:initiatives.doc""")
End Sub
Sub AttachWord(worddoc As Variant, rtitem As NotesRichTextItem, filename$)
'Saves the Ms Word document as filename$ then attaches it as an object to the rich text item. Useful for attaching the Word document to a Notes document
Dim object As NotesEmbeddedObject
Call SaveWord(worddoc, filename$)
Set object = rtitem.EmbedObject( EMBED_ATTACHMENT, "", filename$, "thewordfile" )
Call rtitem.AddNewLine( 1 )
End Sub
Sub SaveWord(worddoc As Variant, filename$)
'Saves the Word document as filename$
worddoc.SaveAs filename$
End Sub
Sub AddWordTextAndLink(worddoc As Variant, mytext$, mylink$)
'Adds the text in mytext$ to the Word document then makes it a link the the address in mylink$ then moves down to the next line
Call worddoc.Activewindow.Selection.TypeText(mytext$)
Call worddoc.Activewindow.Selection.HomeKey(5, 1)
Call worddoc.Hyperlinks.Add(worddoc.Activewindow.Selection.Range, mylink$ , "")
Call worddoc.Activewindow.Selection.TypeText(Chr$(13) + Chr$(13))
End Sub
Sub AddWordText(worddoc As Variant, myText$)
'Adds the text in mytext$ to the Word document then moves down to the next line
Call worddoc.Activewindow.Selection.TypeText(mytext$ + Chr$(13))
End Sub
Sub CloseWord(msword As Variant, worddoc As Variant)
'Closes the Word document then closes the instance of Word
worddoc.Close
msword.Application.Quit
End Sub
This was first published in November 2000