关于调用word问题

zhaolin81 2005-02-03 05:49:08
我用com调用了word程序,然后动态的改动了文档。
可是,我想直接得到改动后的文档的byte[].不希望存储到磁盘上。

各位兄弟有办法吗?
...全文
252 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
yangli_yl2004 2005-06-24
  • 打赏
  • 举报
回复
up
losgou 2005-06-14
  • 打赏
  • 举报
回复
收藏下`!~
真相重于对错 2005-05-09
  • 打赏
  • 举报
回复
楼上的只能存内容,格式呢?插入的图片呢?
不如做个临时文件,存入临时文件,用完再删
ggdayup 2005-05-09
  • 打赏
  • 举报
回复
static void Main(string[] args)
{
//Create a word object that we can manipulate
Word.Application Word_app=new Word.Application();
Word.Document Word_doc=new Word.Document();

//Make Word Application Form visible.
Word_app.Visible=true;

Word.Documents docs=Word_app.Documents;

//open a exist word document.
object template="c:\\temp\\test.dot";
object missing=Type.Missing;
Word_doc=docs.Add(ref template,ref missing,ref missing,ref missing);

// define the selection object, find and replace text
Word.Window myWindow = Word_app.ActiveWindow;
Word.Selection mySelection = myWindow.Selection;
Word.Find myFind = mySelection.Find;
object findText = "alow";
object replaceText ="allow";

// Find "alow" and replace with "allow"

myFind.Execute(ref findText,ref missing,ref missing,ref missing,ref missing,ref missing,ref missing,ref missing,ref missing,ref replaceText,ref missing,ref missing,ref missing,ref missing,ref missing);

//count how many words in your document.
int intEnd=Word_doc.Words.Count; //Define a range to be read to byte[].
object start=0;
object end=intEnd;
Word.Range range=Word_doc.Range(ref start,ref end);
string strText=range.Text;
byte[] buffer=new byte[10000];
//Encoding.ASCII.GetBytes(strText,0,.Length,buffer,0);
Encoding.ASCII.GetBytes(strText,0,strText.Length,buffer,0);
}
zhaolin81 2005-02-04
  • 打赏
  • 举报
回复
没有人知道吗?顶
噯卟釋手 2005-02-04
  • 打赏
  • 举报
回复
up


up


up

110,561

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧