Word Automation Problem

ciaran

New member
Joined
Feb 18, 2004
Messages
4
I am creating word documents on the fly using bookmarks and a .dot template. I would like to pass a datatable with a list of records to a bookmark. Is this possible?
Any help would be appreciated.

here is my code

for(i = 0;i <=10; i++)
{
object newTemplate = "c:\\windowsapp\\stratford_app\\templates\\report.dot";
object filename = "c:\\temp\\test"+i+".doc";
object isVisible = false;
object missing = System.Reflection.Missing.Value;
Word.Document aDoc = WordApp.Documents.Add(ref newTemplate, ref isVisible, ref missing, ref missing);
WordApp.Visible = true;
aDoc.Activate();

object BookMark_Absences = "Absences";
object BookMark_Detentions = "Detentions";

aDoc.Bookmarks.Item(ref BookMark_Absences).Range.Text = "3";
aDoc.Bookmarks.Item(ref BookMark_Detentions).Range.Text = "9";
aDoc.Bookmarks.Item(ref BookMark_Lates).Range.Text = "8";
aDoc.Bookmarks.Item(ref BookMark_Merits).Range.Text = "7";

aDoc.SaveAs(ref filename,ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing,ref missing);
aDoc.Close(ref missing, ref missing, ref missing);
}
 
Back
Top