This example shows how word documents are generated.


dim DB, DIR, WordXML


DB = "#BASEPATH#\Data\Office\Test.mdb"

DIR = "#BASEPATH#\Data\Office"


status = "Create Word documents from MDB..."

MSCreateWordReport("#DIR#\Test.dot", DB, "SELECT * FROM tblTest", "#DIR#", "ID")


'This WordXML will replace values within a word document

WordXML = [<Word>

               <TestText>This Text is used as replacement for 'TestText'</TestText>

               <TestDate>2016-01-01</TestDate>

          </Word>]


status = "Create Word document from XML..."

MSCreateWordReport("#DIR#\Test.dot", WordXML, "#DIR#\XML2Doc.doc")


status = "Open Folder..."

RunCommand = "#DIR#"


Status = "Ready!"



In the “.\Data\Office” folder, a “test.dot” word template and an access database “test.mdb” are used. The query “SELECT FROM tblTest” contains 3 rows, so 3 documents will be generated in the provided folder with a name that is compiled of the Title property of the template and the value from column “ID” of the query. In the document all #FIELDNAME# values are replaced with their appropriate values.


Another way to generate a word document, based on a template, is to use XML input. A single document is generated, based on the XML file. In the template, all #VARIABLENAME# values are replaced with their appropriate values.


The folder is opened by setting RunCommand = Folder path.


Created with the Personal Edition of HelpNDoc: Produce electronic books easily