FAQ>Run-time Assembly

Generating an HTML document while running a Word (or RTF) template

 

Article #:

0043

Contributor:

Daniel Todes

GF version:

All

Applies to:

Automation objects at run time

Last updated:

January 10, 2003

Question

Is it possible to assemble (save and render) an HTML document while running a Microsoft Word or an RTF template?

Answer

You can create an HTML filler automation object at run time by using the CreateObject task in the Word template. If you set the input HTML template to a variable and the output document to a variable, you can then use the HTML filler object to load, fill and render the HTML document.

 

Click here to view a step-by-step example.

  1. Create an HTML filler automation object:

%[htm=CreateObject("gfhtmlfiller.htmlfiller")]

  1. Set the input HTML template to a variable:

%[HTMTemplate=Explorer.MappingToPath(Templates, "GF Feature Samples\4. HTML\Last Will and Testament.htm")]

 

NOTE

This could also be any absolute path outside of the GhostFill Explorer environment.

 

  1. Set the output HTML document to a variable:

%[HTMOutput=Explorer.MappingToPath(Documents, "GF Feature Samples\Last Will and Testament.htm")]

 

NOTE

This could also be any absolute path outside of the GhostFill Explorer environment.

 

  1. Load and assemble the HTML template:

%[~htm.LoadFromFile(HTMTemplate)]

%[~htm.Fill]

  1. Save the assembled HTML string to the specified output file:

%[htm.SaveToFile(HTMOutput)]

  1. Render the HTML file in your browser:

%[x=CreateObject('Shell.Application.1');]

%[x.ShellExecute(HTMOutput,'','','',11);]

  1. Clear the automation objects:

%[htm=""]

%[x=""]