J
Johnny E Jensen
Hello
In the VB6 days i've created a word automation, to create Templates. I've
first created a tab seperated datafile, saved that file, and then using the
following method.
Set NewDoc = App.Documents.Open(Filename:="""" & Templatename & """")
NewDoc.MailMerge.OpenDatasource Name:="""" & MergeFilename & """"
NewDoc.MailMerge.EditMainDocument
And from here the user is now creating the template using the fields from
the datasource, it works just fine.
Now i moved to C# 2005 and have some problems.
_objApplication.Visible = true;
_objApplication.ScreenUpdating = false;
Word.Document objDocument = (Word.Document)_objApplication.Documents.Add(ref
_objMissing, ref _objTrue, ref objType, ref _objTrue);
objDocument.MailMerge.OpenDataSource(mergedatafilename, ref objFormat, ref
_objFalse, ref _objFalse, ref _objMissing, ref _objMissing, ref _objMissing,
ref _objMissing, ref _objMissing, ref _objMissing, ref _objMissing, ref
_objMissing, ref _objMissing, ref _objMissing, ref _objMissing, ref
_objMissing);
Word is displaying a dialog where i'll have to select the field delimiter
used within the datafile - how to awoid this dialog?
And after i click OK i'll get an COM exception error, Word was unable to
open the datasource.
objDocument.SaveAs(ref objName, ref objFile, ref _objMissing, ref
_objMissing, ref _objMissing, ref _objMissing, ref _objMissing, ref
_objMissing, ref _objMissing, ref _objMissing, ref _objMissing, ref
_objMissing, ref _objMissing, ref _objMissing, ref _objMissing, ref
_objMissing);
objDocument.MailMerge.EditMainDocument();
_objApplication.ScreenUpdating = true;
Could anyone please help me.
Kind regards
Johnny E Jensen
In the VB6 days i've created a word automation, to create Templates. I've
first created a tab seperated datafile, saved that file, and then using the
following method.
Set NewDoc = App.Documents.Open(Filename:="""" & Templatename & """")
NewDoc.MailMerge.OpenDatasource Name:="""" & MergeFilename & """"
NewDoc.MailMerge.EditMainDocument
And from here the user is now creating the template using the fields from
the datasource, it works just fine.
Now i moved to C# 2005 and have some problems.
_objApplication.Visible = true;
_objApplication.ScreenUpdating = false;
Word.Document objDocument = (Word.Document)_objApplication.Documents.Add(ref
_objMissing, ref _objTrue, ref objType, ref _objTrue);
objDocument.MailMerge.OpenDataSource(mergedatafilename, ref objFormat, ref
_objFalse, ref _objFalse, ref _objMissing, ref _objMissing, ref _objMissing,
ref _objMissing, ref _objMissing, ref _objMissing, ref _objMissing, ref
_objMissing, ref _objMissing, ref _objMissing, ref _objMissing, ref
_objMissing);
Word is displaying a dialog where i'll have to select the field delimiter
used within the datafile - how to awoid this dialog?
And after i click OK i'll get an COM exception error, Word was unable to
open the datasource.
objDocument.SaveAs(ref objName, ref objFile, ref _objMissing, ref
_objMissing, ref _objMissing, ref _objMissing, ref _objMissing, ref
_objMissing, ref _objMissing, ref _objMissing, ref _objMissing, ref
_objMissing, ref _objMissing, ref _objMissing, ref _objMissing, ref
_objMissing);
objDocument.MailMerge.EditMainDocument();
_objApplication.ScreenUpdating = true;
Could anyone please help me.
Kind regards
Johnny E Jensen