object oMissing = System.Reflection.Missing.Value;
object oEndOfDoc = "\\endofdoc"; /* \endofdoc is a predefined book *///Start Word and create a new document.
Word._Application oWord;
Word._Document oDoc;
oWord = new Word.Application();
oWord.Visible = true;
object oTemplate = "d:\\f\\word\\MyTemplate.dot";
oDoc = oWord.Documents.Add(ref oTemplate, ref oMissing,
ref oMissing, ref oMissing);object oMissing = System.Reflection.Missing.Value;
object oEndOfDoc = "\\endofdoc"; /* \endofdoc is a predefined book *///Start Word and create a new document.
Word._Application oWord;
Word._Document oDoc;
oWord = new Word.Application();
oWord.Visible = true;
object oTemplate = "d:\\f\\word\\MyTemplate.dot";
oDoc = oWord.Documents.Add(ref oTemplate, ref oMissing,
ref oMissing, ref oMissing);
object oBookMark = "MyBook";
Word.Table oTable;
Word.Range wrdRng = oDoc.Books.Item(ref MyBook).Range;//(错误在这句)
object oEndOfDoc = "\\endofdoc"; /* \endofdoc is a predefined book *///Start Word and create a new document.
Word._Application oWord;
Word._Document oDoc;
oWord = new Word.Application();
oWord.Visible = true;
object oTemplate = "d:\\f\\word\\MyTemplate.dot";
oDoc = oWord.Documents.Add(ref oTemplate, ref oMissing,
ref oMissing, ref oMissing);object oMissing = System.Reflection.Missing.Value;
object oEndOfDoc = "\\endofdoc"; /* \endofdoc is a predefined book *///Start Word and create a new document.
Word._Application oWord;
Word._Document oDoc;
oWord = new Word.Application();
oWord.Visible = true;
object oTemplate = "d:\\f\\word\\MyTemplate.dot";
oDoc = oWord.Documents.Add(ref oTemplate, ref oMissing,
ref oMissing, ref oMissing);
object oBookMark = "MyBook";
Word.Table oTable;
Word.Range wrdRng = oDoc.Books.Item(ref MyBook).Range;//(错误在这句)
解决方案 »
- 急:firefox的firebug中html功能很有用,原理是什么?
- C#解析htm的内容
- 问一个菜鸟问题?xml如何绑定成treeview?
- OleDb.OleDbDataAdapter.Update() 的问题,老是报出 INSERT INTO 语句的语法错误 ,请大家帮我看看
- 问一个HTML控件 赋值的问题???
- ===关于日期类型的判断问题===
- ref out 概念问题
- Socket的推送和调用同时进行
- 有带checkbox的treeview控件吗?
- 局域网内怎样实现媒体点播(浏览器 方式)!
- 如何在C#中打开一个excel文件,并在程序界面上显示出来?
- 文件打包问题?解决马上结帖.
ref MyBook--MyBook你没有定义啊!
单独编译slope为windows应用程序运行是没有问题的。只是编译为DLL,然后被work项目引用就出现问题了。
{
oDoc = oWord.Documents.Add(ref oTemplate, ref oMissing,
ref oMissing, ref oMissing);
}
else
{
MessageBox.Show("Null");
}
{
oDoc = oWord.Documents.Add(ref oTemplate, ref oMissing,
ref oMissing, ref oMissing);
}
else
{
MessageBox.Show("Null");
}
应该是oDoc.Books.Item(ref MyBook)为null,在slope编译的windows应用程序,执行那段没有问题。把他编译为dll被work引用的时候,slope作为work窗体的一个子窗体,这种情况下就不行了。
调用slope.dll的代码是:Assembly asm = Assembly.LoadFile(System.Windows.Forms.Application.StartupPath+"\\slope.dll");
Type formType = asm.GetType("slope.Form1");
Form[] charr = this.MdiChildren;
Form frm = OpenForm(formType);Form OpenForm(Type formType)
{
Form frm = formType.InvokeMember(null,
BindingFlags.DeclaredOnly
| BindingFlags.Public
| BindingFlags.NonPublic
| BindingFlags.Instance
| BindingFlags.CreateInstance,
null, null, null) as Form;
frm.MdiParent = this;
frm.Show();
return frm;
}
是这句的路径不对。