Daily Archives: January 25, 2006

Lost

I find I am lost again, everything is in a mess and I just don’t know what to do. Something I tought was so important turns out so frustrating, something I thought was so simple now seems a NP problem.

I’ve suffered from insomnia for days. I lain in bed and was thinking over these shits for hours.

I was turned down many times these years, each time it was a real blow and I don’t know how I went though. This time, all seems goes fine, but I’m unassured what would happen. Where the hell my courage comes from this time ? I don’t know, all I know is that it is there and seize it or never shall I. I’ve lost to many chances, I just cann’t miss it this time.The whole thing is like a bottle of milk.At first it is as pure as a virgin, then, as time goes by, it changes by mixing things like money, house, departure, etc , and at last it goes bad.It is changing now. If I missed the best time , I got to save it until too late.

However, there are too much to think about. I am a little scared. Maybe that is why I cann’t fall in asleep. Here I want to make it clear that I am not a smart guy. I am a little dummy indeed, at least in EQ. Well, all in all , I hope everything will get better, the futher, the feeling and the family.

将word文档转化为其他格式

以前看到google能搜索office文档,心里想,对于google来说,其中的难点在于doc到文本格式的转化,这是是怎么完成的呢?

其实这一步在Office提供的COM 中就可以解决了.以C#为例,我们来看看如何将word文档转化为其他的各种格式.

首先,我们需要添加引用(Solution Explorer中右击选择Add Reference… ),选择COM中的Microsoft Word 11.0 Object Library。

然后,添加代码:

[coolcode lang=”java”]
object objFileName = ((object)”sampleWordFile.doc”);
Word.Application Word_App = null;
Word.Document Word_doc = null;
Word_App = new Word.Application();
Word_doc = new Word.Document();
Word.Documents Docs = Word_App.Documents;
Word_App.Visible = false;
//Open File
Word_doc = Docs.Open(ref objFileName, ref missing, ref missing,
ref missing, ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing, ref missing,ref missing,
ref missing, ref missing, ref missing);
object format = null;
object tempfile = null;

format = Word.WdSaveFormat.wdFormatText;
tempfile = “c:/temp.txt”;
Word_App.ActiveDocument.SaveAs(ref tempfile, ref format, ref missing, ref missing,
ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing, ref missing, ref missing);
Word_doc.Close(ref missing, ref missing, ref missing);
[/coolcode]

这样就将 sampleWordFile.doc转化为c:/temp.txt。同样的,我们可以设置
[coolcode lang=”java”]
format = Word.WdSaveFormat.wdFormatRTF;
[/coolcode]
这样,可以转化为rtf格式,甚至是html、xml格式,等等。
word.jpg

BTW,CoolCode 没有专门的CSharp语法,所以只能用java代用了,效果还不错。两者语法真的好像,汗……