C#插入WORD模版出错
Word.Application oWord;
Word._Document oDoc;
//Word._Document aDoc;
object oMissing = System.Reflection.Missing.Value;
object Source = Server.MapPath( "doc1.doc ");
object Unknown =Type.Missing;
oWord = new Word.Application();
try
{
oDoc = oWord.Documents.Open(ref Source,ref Unknown,ref Unknown,ref Unknown,ref Unknown,ref Unknown,ref Unknown,ref Unknown,ref Unknown,ref Unknown,ref Unknown,ref Unknown );
//aDoc = oWord.Documents.Add(ref Source,ref Unknown,ref Unknown,ref Unknown);
Word.Document wordDoc=oWord.Documents.Add(ref Source,ref oMissing,ref oMissing,ref oMissing);
String i;
i=oDoc.Tables.Item(2).Cell(1,2).Range.Text.ToString();
Label1.Text=i.Substring(0,i.Length-2);
Label2.Text=oDoc.Tables.Count.ToString();
String o;
o=TextBox1.Text;
wordDoc.Tables.Item(2).Cell(2,2).Range.InsertAfter(o);
读取的这样对吧?可是插入时老是没反应,要不就出错.大家能不能在我上面这个改动,还是这样写是错的?
------解决方案--------------------1.报什么错?
2.doc1.doc是放在应用程序根目录下面,设置可写权限没?
3.工程里面引用office控件没有?
------解决方案--------------------Word - 特殊符号不见了? 也谈 Normal.dot
Word - 特殊符号不见了? 也谈 Normal\.dot
Word [插入] > [特殊符号] 不见了吗?
关闭 Word > 搜寻 Normal\.dot 并删除 > 开启 Word。