S
Sean Connolly
Hi,
I have written a .NET application in C# which uses automation to control
Word and Excel.
On the application which renders Word documents, I wish to email the
rendered document to a recipient. I have found some code to setup and perform
the ActiveDocument.route() function and this works fine on my development PCs
(Office 2003).
One of our other office PCs came with Office 2007 installed. The application
runs fine there (once I realised a couple of glitches with the rendering of
the documents), but the ActiveDocument.Route() function seems to crash.
Can someone please take a look at the code below and tell me why this won't
work on Office 2007?
Thanks in advance.
Sean
using Word = Microsoft.Office.Interop.Word;
Word.Application wordApp = new Word.Application();
Word.Document wordDoc = new Word.Document;
string Subject = "Your data extract is complete!";
wordApp.ActiveDocument.HasRoutingSlip = true;
wordApp.ActiveDocument.RoutingSlip.Subject = Subject;
object Unknown = Type.Missing;
object Target = "C:\\" + AZStationInsert.SelectedStation[1].ToString() +
".doc";
object LockComments = false;
object FileFormat = Unknown;
object Password = Unknown;
object AddToRecentFiles = true;
object WritePassword = Unknown;
object ReadOnlyRecommended = false;
object EmbedTrueTypeFonts = false;
object SaveNativePictureFormat = false;
object SaveFormsData = false;
object SaveAsAOCELetter = false;
object Encoding = Unknown;
object InsertLineBreaks = false;
object AllowSubstitutions = false;
object LineEnding = Microsoft.Office.Interop.Word.WdLineEndingType.wdCRLF;
object AddBiDiMarks = false;
wordApp.ActiveDocument.SaveAs(ref Target, ref FileFormat, ref LockComments,
ref Password, ref AddToRecentFiles, ref WritePassword, ref
ReadOnlyRecommended, ref EmbedTrueTypeFonts, ref SaveNativePictureFormat, ref
SaveFormsData, ref SaveAsAOCELetter, ref Encoding, ref InsertLineBreaks,
ref AllowSubstitutions, ref LineEnding, ref AddBiDiMarks);
wordApp.ActiveDocument.RoutingSlip.AddRecipient(OutputFilePath);
wordApp.ActiveDocument.RoutingSlip.Delivery =
Word.WdRoutingSlipDelivery.wdAllAtOnce;
wordApp.ActiveDocument.Route();
I have written a .NET application in C# which uses automation to control
Word and Excel.
On the application which renders Word documents, I wish to email the
rendered document to a recipient. I have found some code to setup and perform
the ActiveDocument.route() function and this works fine on my development PCs
(Office 2003).
One of our other office PCs came with Office 2007 installed. The application
runs fine there (once I realised a couple of glitches with the rendering of
the documents), but the ActiveDocument.Route() function seems to crash.
Can someone please take a look at the code below and tell me why this won't
work on Office 2007?
Thanks in advance.
Sean
using Word = Microsoft.Office.Interop.Word;
Word.Application wordApp = new Word.Application();
Word.Document wordDoc = new Word.Document;
string Subject = "Your data extract is complete!";
wordApp.ActiveDocument.HasRoutingSlip = true;
wordApp.ActiveDocument.RoutingSlip.Subject = Subject;
object Unknown = Type.Missing;
object Target = "C:\\" + AZStationInsert.SelectedStation[1].ToString() +
".doc";
object LockComments = false;
object FileFormat = Unknown;
object Password = Unknown;
object AddToRecentFiles = true;
object WritePassword = Unknown;
object ReadOnlyRecommended = false;
object EmbedTrueTypeFonts = false;
object SaveNativePictureFormat = false;
object SaveFormsData = false;
object SaveAsAOCELetter = false;
object Encoding = Unknown;
object InsertLineBreaks = false;
object AllowSubstitutions = false;
object LineEnding = Microsoft.Office.Interop.Word.WdLineEndingType.wdCRLF;
object AddBiDiMarks = false;
wordApp.ActiveDocument.SaveAs(ref Target, ref FileFormat, ref LockComments,
ref Password, ref AddToRecentFiles, ref WritePassword, ref
ReadOnlyRecommended, ref EmbedTrueTypeFonts, ref SaveNativePictureFormat, ref
SaveFormsData, ref SaveAsAOCELetter, ref Encoding, ref InsertLineBreaks,
ref AllowSubstitutions, ref LineEnding, ref AddBiDiMarks);
wordApp.ActiveDocument.RoutingSlip.AddRecipient(OutputFilePath);
wordApp.ActiveDocument.RoutingSlip.Delivery =
Word.WdRoutingSlipDelivery.wdAllAtOnce;
wordApp.ActiveDocument.Route();