在用word替换的功能时,一般的word都可以替换成功,但是word文本框里面的内容替换不到,经发现,当光标最后停留在文本框内的时候,就可以替换成功。
有没有办法解决无论光标在哪,都可以替换成功。求代码!
有没有办法解决无论光标在哪,都可以替换成功。求代码!
解决方案 »
- pdf的韩文内容显示
- 为何treeview1不显示数据
- 询问checkbox的控件与老checkbox的区别
- [求助]未能加载文件或程序集错误
- 如何改变窗体(form)的形状, 我想把一张圆形图片贴在窗体上, 窗体变为该圆形, 而不是四四方方的窗体。
- winform TabControl控件的标签页中怎么加载一个窗体
- DataGridView的改写
- 求一个正则表达式
- 求助,为什么DownloadProgressChangedEventArgs .TotalBytesToReceive这个值一直是-1
- 网页在IE下显示不出来进度条
- 有关PDA中数据的读取操作
- C#操作excel,quit后任务管理器重现实还是存在EXCEL.EXT进程。
其实也考虑过移动光标的方法,但是不知道怎样将光标移到文本框内.
object oMissing = System.Reflection.Missing.Value;
Microsoft.Office.Interop.Word._Application oWord;
Microsoft.Office.Interop.Word._Document oDoc;
oWord = new Microsoft.Office.Interop.Word.Application();
oWord.Visible = false;
object fileName = "文件路径";
oDoc = oWord.Documents.Open(ref fileName, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing); object FindText, ReplaceWith, Replace;
Replace = Microsoft.Office.Interop.Word.WdReplace.wdReplaceAll; foreach (Microsoft.Office.Interop.Word.Shape shapex in oDoc.Shapes)
{
shapex.Select(ref oMissing); FindText = "old";//要查找的文本
ReplaceWith = "new";//替换文本
oWord.Selection.Find.Execute(ref FindText, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref ReplaceWith, ref Replace, ref oMissing, ref oMissing, ref oMissing, ref oMissing);
} oDoc.Save(); if (oDoc != null)
oDoc.Close(ref oMissing, ref oMissing, ref oMissing);
if (oWord != null)
oWord.Quit(ref oMissing, ref oMissing, ref oMissing);
报错 什么原因System.Runtime.InteropServices.COMException: 占位程序接收到错误数据