G
Guest
Hi
I'm working on a Word 2003 mail merge component for a windows client.
My problem is that the BeforePrint Event ist not raised if the user is
printing directly out of word, but if I'm running the PrintOut command in the
code it is working!
I'm using Office 2003 with the appropriate PIA's.
The code looks like this:
public void Preview()
{
Document wordDoc = OpenDocument();
wordDoc.Application.Visible = true;
}
privat e Document OpenDocument()
{
Document wordDoc = null;
ApplicationClass wordApp = new ApplicationClass();
wordApp.DocumentBeforePrint += new
ApplicationEvents4_DocumentBeforePrintEventHandler(WordPrint_BeforePrint);
try
{
wordDoc = wordApp.Documents.Add(ref template, ref _missingValue,
ref
_missingValue, ref _trueValue);
wordDoc.MailMerge.Destination =
WdMailMergeDestination.wdSendToNewDocument;
wordDoc.MailMerge.Execute(ref _falseValue);
wordApp.ActiveDocument.SaveAs(ref fileName, ref _missingValue, ref
_missingValue, ref _missingValue, ref _missingValue, ref _missingValue, ref
_missingValue, ref _missingValue, ref _missingValue, ref _missingValue, ref
_missingValue, ref _missingValue, ref _missingValue, ref _missingValue, ref
_missingValue, ref _missingValue);
wordApp.Documents.Close(ref _falseValue, ref _missingValue, ref
_missingValue);
wordDoc = wordApp.Documents.Open(ref fileName, ref _missingValue,
ref _missingValue, ref _missingValue, ref _missingValue, ref _missingValue,
ref _missingValue, ref _missingValue, ref _missingValue, ref _missingValue,
ref _missingValue, ref _trueValue, ref _missingValue, ref _missingValue, ref
_missingValue, ref _missingValue);
}
private void WordPrint_BeforePrint(Microsoft.Office.Interop.Word.Document
doc, ref bool cancel)
{
// Do some stuff
}
It is really important that I can catch the BeforePrint event for my
application.
Can anyone help me?
Thanks
Nicolas
I'm working on a Word 2003 mail merge component for a windows client.
My problem is that the BeforePrint Event ist not raised if the user is
printing directly out of word, but if I'm running the PrintOut command in the
code it is working!
I'm using Office 2003 with the appropriate PIA's.
The code looks like this:
public void Preview()
{
Document wordDoc = OpenDocument();
wordDoc.Application.Visible = true;
}
privat e Document OpenDocument()
{
Document wordDoc = null;
ApplicationClass wordApp = new ApplicationClass();
wordApp.DocumentBeforePrint += new
ApplicationEvents4_DocumentBeforePrintEventHandler(WordPrint_BeforePrint);
try
{
wordDoc = wordApp.Documents.Add(ref template, ref _missingValue,
ref
_missingValue, ref _trueValue);
wordDoc.MailMerge.Destination =
WdMailMergeDestination.wdSendToNewDocument;
wordDoc.MailMerge.Execute(ref _falseValue);
wordApp.ActiveDocument.SaveAs(ref fileName, ref _missingValue, ref
_missingValue, ref _missingValue, ref _missingValue, ref _missingValue, ref
_missingValue, ref _missingValue, ref _missingValue, ref _missingValue, ref
_missingValue, ref _missingValue, ref _missingValue, ref _missingValue, ref
_missingValue, ref _missingValue);
wordApp.Documents.Close(ref _falseValue, ref _missingValue, ref
_missingValue);
wordDoc = wordApp.Documents.Open(ref fileName, ref _missingValue,
ref _missingValue, ref _missingValue, ref _missingValue, ref _missingValue,
ref _missingValue, ref _missingValue, ref _missingValue, ref _missingValue,
ref _missingValue, ref _trueValue, ref _missingValue, ref _missingValue, ref
_missingValue, ref _missingValue);
}
private void WordPrint_BeforePrint(Microsoft.Office.Interop.Word.Document
doc, ref bool cancel)
{
// Do some stuff
}
It is really important that I can catch the BeforePrint event for my
application.
Can anyone help me?
Thanks
Nicolas