Today i received an email ask for help to integrate domino and MS word using lotus script code.
Below was my reply, hope it works for you.
Dim objWord As Variant
Set objWord = CreateObject("Word.Application")
Dim objDoc As Variant
Set objDoc = objWord.Documents.Add([TemplateName])
[TemplateName] should be replaced; either by "normal.dot" (the name of the default template that word uses when creating a new empty document) or by Your own template. This gives You the option of creating Your own template with all the things that should be the same on every document; headers, footers, font styles, borders etc...
If You have added bookmarks in the word document, You will write to them like this:
objDoc.FormFields("NameOfBookmark").Result = "some test to write here..."
If You don't use bookmarks, then simply add text like this:
objWord.Selection.InsertAfter " some text to write here..."
to add tables into the word document use below code
Set range = objWord.Selection.Range
Set table = objDoc.Tables.Add(range,6,5)
table.Cell(1, 1).Range.InsertAfter ("cell 11")
table.Cell(1, 2).Range.InsertAfter ("cell 12")
table.Cell(1, 3).Range.InsertAfter ("cell 13")
table.Cell(1, 4).Range.InsertAfter ("cell 14")
table.Cell(1, 5).Range.InsertAfter ("cell 15")
When all text has been written as You want it, then simply save the document.
objDoc.SaveAs([FullFilePath])
The filepath should be provided with the full name, like "C:\Temp\mytestdocument.docx".Now, the document is saved, but the word document is still present in the memory (as well as the word application object). They has to be removed:
objDoc.Close
Set objDoc = Nothing
objWord.Quit
Set objWord = Nothing
Below was my reply, hope it works for you.
Dim objWord As Variant
Set objWord = CreateObject("Word.Application")
Dim objDoc As Variant
Set objDoc = objWord.Documents.Add([TemplateName])
[TemplateName] should be replaced; either by "normal.dot" (the name of the default template that word uses when creating a new empty document) or by Your own template. This gives You the option of creating Your own template with all the things that should be the same on every document; headers, footers, font styles, borders etc...
If You have added bookmarks in the word document, You will write to them like this:
objDoc.FormFields("NameOfBookmark").Result = "some test to write here..."
If You don't use bookmarks, then simply add text like this:
objWord.Selection.InsertAfter " some text to write here..."
to add tables into the word document use below code
Set range = objWord.Selection.Range
Set table = objDoc.Tables.Add(range,6,5)
table.Cell(1, 1).Range.InsertAfter ("cell 11")
table.Cell(1, 2).Range.InsertAfter ("cell 12")
table.Cell(1, 3).Range.InsertAfter ("cell 13")
table.Cell(1, 4).Range.InsertAfter ("cell 14")
table.Cell(1, 5).Range.InsertAfter ("cell 15")
When all text has been written as You want it, then simply save the document.
objDoc.SaveAs([FullFilePath])
The filepath should be provided with the full name, like "C:\Temp\mytestdocument.docx".Now, the document is saved, but the word document is still present in the memory (as well as the word application object). They has to be removed:
objDoc.Close
Set objDoc = Nothing
objWord.Quit
Set objWord = Nothing