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.Offic e.Interop.Word;
----
Word.Applicatio n WordApp = new
Microsoft.Offic e.Interop.Word. Application();
object missing = System.Reflecti on.Missing.Valu e;
object falseValue = false;
object trueValue = true;
private void WordProcess(str ing openDoc, string openXls, string saveDoc)
{
object fileName = openDoc;
Word.Document doc = WordApp.Documen ts.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.O penDataSource(l inkTo.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.E xecute(ref missing);
}
catch (Exception ex){}
finally
{
try
{
//doc.Save();//save word
CloseApp();//close word app
}
catch (Exception ex) {}
}
}
private void CloseApp()
{
WordApp.Documen ts.Close(ref trueValue, ref missing, ref missing);
WordApp.Quit(re f trueValue, ref missing, ref missing);
System.Runtime. InteropServices .Marshal.Releas eComObject(Word App);
GC.Collect();
//this.KillExcelP rocess();
}
*** Sent via Developersdex http://www.developersdex.com ***