EX:
object nRef = Type.Missing;
object falseRef = false;
object trueRef = true;
object oEndOfDoc = "\\endofdoc "; /* \endofdoc is a predefined bookmark */
try
{
word = new Word.Applicatio n();
word.Visible = false;
object path = this.templateDi rectory + this.ClientTemp late;
Word._Document dc = word.Documents. Add(ref path,ref nRef,ref nRef,ref
trueRef);
//Date
object dDisplay = "Date";
dc.Bookmarks.It em(ref dDisplay).Range .Text = this.DateDispla yed;
//App names
//First name
object fName = "FirstName" ;
dc.Bookmarks.It em(ref fName).Range.Te xt = this.FirstName;
object lName = "LastName";
dc.Bookmarks.It em(ref lName).Range.Te xt = this.LastName;
object addr = "Address";
dc.Bookmarks.It em(ref addr).Range.Tex t = this.Address;
object aCity = "City";
dc.Bookmarks.It em(ref aCity).Range.Te xt = this.City;
object aState = "State";
dc.Bookmarks.It em(ref aState ).Range.Text = this.State;
object aZip = "Zip";
dc.Bookmarks.It em(ref aZip).Range.Tex t = this.Zip;
object openName = "OpenName";
dc.Bookmarks.It em(ref openName).Range .Text = this.FirstName;
object openNameLast = "OpenNameLa st";
dc.Bookmarks.It em(ref openNameLast).R ange.Text = this.LastName;
object sig = "Signature" ;
dc.Bookmarks.It em(ref sig).Range.Text = this.Signature;
///Use this name to save this file
object fileName = generateFileNam e();
object savePath = this.WorkingDir ectory + 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.ToStri ng();
}
catch (Exception ex)
{
this.lastError = ex.ToString();
}
finally
{
if (word != null)
word.Quit(ref falseRef,ref nRef,ref nRef);
}
HTH,
Alex
"Ruslan Shlain" <rs*****@hotmai l.com> wrote in message
news:O0******** ******@TK2MSFTN GP12.phx.gbl...
Hello everyone.
I have a question that I tried to find an answer over the weekend but did
not succeeded.
I have a Word template with a couple of "tags" ( <<My Tag>>) that I need
to replace with data from the DB. Please point me in the right direction on
how to approach this. Code samples, links or articles. Anything would work.
Thank you very much in advance.