EX:
object nRef = Type.Missing;
object falseRef = false;
object trueRef = true;
object oEndOfDoc = "\\endofdoc"; /* \endofdoc is a predefined bookmark */
try
{
word = new Word.Application();
word.Visible = false;
object path = this.templateDirectory + this.ClientTemplate;
Word._Document dc = word.Documents.Add(ref path,ref nRef,ref nRef,ref
trueRef);
//Date
object dDisplay = "Date";
dc.Bookmarks.Item(ref dDisplay).Range.Text = this.DateDisplayed;
//App names
//First name
object fName = "FirstName";
dc.Bookmarks.Item(ref fName).Range.Text = this.FirstName;
object lName = "LastName";
dc.Bookmarks.Item(ref lName).Range.Text = this.LastName;
object addr = "Address";
dc.Bookmarks.Item(ref addr).Range.Text = this.Address;
object aCity = "City";
dc.Bookmarks.Item(ref aCity).Range.Text = this.City;
object aState = "State";
dc.Bookmarks.Item(ref aState ).Range.Text = this.State;
object aZip = "Zip";
dc.Bookmarks.Item(ref aZip).Range.Text = this.Zip;
object openName = "OpenName";
dc.Bookmarks.Item(ref openName).Range.Text = this.FirstName;
object openNameLast = "OpenNameLast";
dc.Bookmarks.Item(ref openNameLast).Range.Text = this.LastName;
object sig = "Signature";
dc.Bookmarks.Item(ref sig).Range.Text = this.Signature;
///Use this name to save this file
object fileName = generateFileName();
object savePath = this.WorkingDirectory + fileName;
dc.SaveAs(ref savePath,ref nRef,ref nRef,ref nRef,ref falseRef,ref nRef,ref
nRef,
ref nRef,ref trueRef,ref nRef,ref nRef);
return savePath.ToString();
}
catch (Exception ex)
{
this.lastError = ex.ToString();
}
finally
{
if (word != null)
word.Quit(ref falseRef,ref nRef,ref nRef);
}
HTH,
Alex