Hi,
I want to open a word file on background instead of showing the process
on client's screen. And then do mailmerge, after that allow user to
saveas. (user simply click the button and IE will ask user to open or
save as the file)
Below is the code but I donno how to do it on background. It's an aspx
program, thanks.
Ang
using Word = Microsoft.Office.Interop.Word;
----
Word.Application WordApp = new
Microsoft.Office.Interop.Word.Application();
object missing = System.Reflection.Missing.Value;
object falseValue = false;
object trueValue = true;
private void WordProcess(string openDoc, string openXls, string saveDoc)
{
object fileName = openDoc;
Word.Document doc = WordApp.Documents.Open(ref fileName, ref missing,
ref falseValue, ref missing, ref missing, ref missing, ref missing, ref
missing, ref missing, ref missing, ref missing, ref trueValue, ref
missing, ref missing, ref missing, ref missing);
object linkTo = openXls;
object query = "SELECT * FROM `DataSource$`";
try
{
doc.MailMerge.OpenDataSource(linkTo.ToString(), ref missing, ref
missing, ref missing, ref trueValue, ref missing, ref missing, ref
missing, ref missing, ref missing, ref missing, ref missing, ref query,
ref missing, ref missing, ref missing);
doc.MailMerge.Execute(ref missing);
}
catch (Exception ex){}
finally
{
try
{
//doc.Save();//save word
CloseApp();//close word app
}
catch (Exception ex) {}
}
}
private void CloseApp()
{
WordApp.Documents.Close(ref trueValue, ref missing, ref missing);
WordApp.Quit(ref trueValue, ref missing, ref missing);
System.Runtime.InteropServices.Marshal.ReleaseComO bject(WordApp);
GC.Collect();
//this.KillExcelProcess();
}
*** Sent via Developersdex http://www.developersdex.com ***