江湖救急。 关于ASP.NET环境操作Word文档.
过程如下: 客户端用IE上传一图片a.bmp并保存在upfile文件夹下,将其插入到服务端同一文件夹下的Word文档b.doc。并保存b.doc。
我使用Msword9.olb。
图片上传成功, 但当使用wordApp.Documents.Open()方法打开b.doc时却出现异常。
System.Runtime.InteropServices.COMException: 无法打开宏储存。Word.Document wordDoc = wordApp.Documents.Open(ref FileName,
ref Nothing,ref ReadOnly,ref Nothing,ref Nothing,ref Nothing,ref Nothing,ref Nothing,ref Nothing,ref Nothing,ref Nothing,ref Nothing);
//FileName为b.doc的绝对路径"c:\inetpub\wwwroot\attribute\upload\519456.doc"
该怎么办? 帮帮忙。
问题点数:0、回复次数:6Top
1 楼liuwei662656(天堂)回复于 2003-11-02 16:41:10 得分 0
SOSTop
2 楼liuwei662656(天堂)回复于 2003-11-02 16:46:31 得分 0
同样的代码转换成WinForm就好使, 在WebForm下就不行。
哪路神仙帮忙。
谢先。Top
3 楼nbbg(乐天)回复于 2003-11-02 17:00:18 得分 0
upTop
4 楼rgbcn(奔向.net)回复于 2003-11-02 17:43:30 得分 0
object fileName = openFileDialog1.FileName;
object readOnly = false;
object isVisible = true;
// Here is the way to handle parameters you don't care about in .NET
object missing = System.Reflection.Missing.Value;
// Make word visible, so you can see what's happening
WordApp.Visible = true;
// Open the document that was chosen by the dialog
Word.Document aDoc = WordApp.Documents.Open(ref fileName, ref missing,ref readOnly, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref isVisible);
// Activate the document so it shows up in front
aDoc.Activate();
///////////////////////////////////////////////////////
用以上参数传进去试试,把nothing 改一下。
Top
5 楼rgbcn(奔向.net)回复于 2003-11-02 17:43:47 得分 0
see
http://www.c-sharpcorner.com/Code/2002/Mar/WordFromDotNet.aspTop
6 楼liuwei662656(天堂)回复于 2003-11-02 17:58:13 得分 0
那篇文章写的是在Winform下。
我的程序改成Winform下的也好使, 但不知为什么在WebForm就over了。Top




