|
直接贴代码了,知道的大神帮帮忙!!!多谢了!!
Word.Application word = null;
Word.Document doc;
try
{
word = (Word.Application)Marshal.GetActiveObject("Word.Application");//判断是否有活动 //application对象,并强制转换
}
catch
{
word = null;
}
if (word == null)
{
word = new Word.Application();
}
try
{
if (lanaguerSet == 0)
{
doc= word.Documents.Add(@"C:\AK-office\27个模板更正版\8-传真件\Fax_cn.dotx");
}}
创建完新的文件后,总是被挡住,怎么能把新文档窗体,到最前端显示!!
}
catch (Exception ex)
{
ErrLog.systemlogwinFrom2(ex.ToString(), "jdErr", strPath);
}
finally
{
if (word != null)
{
word.Visible = true;// show the document even if there was some error - otherwise it will be residing hidden in the process list
//word.ActiveDocument.Activate();
// if there is more than 1 document opened, it will bring the new one on top.
//word.ActiveDocument.top //Word.Application word = null;// should bring the word application on top - does not work on Vista / Windows 7
//private System.ComponentModel.Container components = null;
//word.ActiveDocument.ActiveWindow(doc);
System.Windows.Forms.Application.DoEvents();// should bring the word application on top - does not work on Vista / Windows 7
}
}
用这个 activate();方法也不灵啊!
|
|