日期:2014-05-20  浏览次数:21092 次

还是老问题。
异常详细信息: System.Runtime.InteropServices.COMException: 命令失败

堆栈跟踪: 
[COMException (0x800a1066): 命令失败]
  Microsoft.Office.Interop.Word.DocumentClass.SaveAs(Object& FileName, Object& FileFormat, Object& LockComments, Object& Password, Object& AddToRecentFiles, Object& WritePassword, Object& ReadOnlyRecommended, Object& EmbedTrueTypeFonts, Object& SaveNativePictureFormat, Object& SaveFormsData, Object& SaveAsAOCELetter, Object& Encoding, Object& InsertLineBreaks, Object& AllowSubstitutions, Object& LineEnding, Object& AddBiDiMarks) +0

//初期化
Word._Application WordApp = new Word.Application();
Word._Document WordDoc;
 
//创建
WordDoc = WordApp.Documents.Add(ref Nothing, ref Nothing, ref Nothing, ref objTrue);

//保存
WordDoc.SaveAs(ref filename, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing);//回收 --------跑到这里就出错,所有保存的方法都出错,包括save save2000
WordDoc.Close(ref Nothing, ref Nothing, ref Nothing);
WordApp.Quit(ref Nothing, ref Nothing, ref Nothing);
System.Runtime.InteropServices.Marshal.ReleaseComObject(WordApp);



补充一点,我的机器是 32位 windows2008 office2003 iis6. 服务器是 64位 windows2008 office 2003 iis7.0 兼容6.0 

现在就是出这个错,能走到Saveas说明有权限去创建一个模板,但是就是在另存为的时候出这个错误,到底是那块的权限配错了啊?我权限用的是管理员的账号密码。希望高手指点指点。
还有就是如果我open一个doc的时候也出错,但是那个错是:内存不足,什么什么的,,既不太清了,我觉得上个问题解决了,这个问题也就不是问题了。

------解决方案--------------------
2008的权限比2003严格多了
Change the configuration from Any CPU to x86

------解决方案--------------------
这应该还是IIS上用户设置的权限不够。。
------解决方案--------------------
http://topic.csdn.net/u/20090909/10/4a6d44df-ead6-42e8-898b-39d33c225c93.html
------解决方案--------------------
看看文件夹权限