泪奔求助:System.Runtime.InteropServices.COMException:命令失败
代码:(红色为出错地方)
Microsoft.Office.Interop.Word._Application oWord = null;
Microsoft.Office.Interop.Word._Document oDoc;
oWord = new Microsoft.Office.Interop.Word.Application();
//oWord.Visible = true;
object ReadOnly = true;
oWord.ActivePrinter = "Microsoft Office Document Image Writer";
oDoc = oWord.Documents.Open(ref tempFileName,
ref oMissing, ref ReadOnly, 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);
try
{
// if (!Directory.Exists(savePath.ToString()))
// {
// Directory.CreateDirectory(savePath.ToString());
// }
savePath = sPath;//+ strFileName + "." + astdt;
object format = Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatPDF;
oDoc.SaveAs(ref savePath, ref format,
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);
Microsoft.Office.Interop.Word.WdStatistic stat = Microsoft.Office.Interop.Word.WdStatistic.wdStatisticPages;
pageNum = oDoc.ComputeStatistics(stat, ref oMissing);
错误信息:
捕捉到 System.Runtime.InteropServices.COMException
HelpLink="C:\\Program Files\\Microsoft Office\\Office12\\2052\\WDMAIN11.CHM#36966"
Message="命令失败"
Source="Microsoft Word"
ErrorCode=-2146824090
StackTrace:
在 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)
在 UploadSystem.Doc2Swf.ToPdf(String path, String sPath, String sImagesPath) 位置 E:\web\Wendang\UploadSystem\Convert.cs:行号 66
InnerException: null
GG了2天 说COM权限问题,如是在能加权限的地方全加上了 例如组件服务的WORD启动和访问权限 还是报错 去年遇到过一次这样的错误,后来解决了,但是忘了怎么解决的,泪奔啊,我的天那,我一个地方载了2次了,请各位救救我吧,不然我投河了。
相关推荐
System.Runtime.InteropServices.COMException的解决方法
完美解决“换另一台电脑上用VS2008继续开发web项目时出现 “System.Runtime.InteropServices.COMException”,然后是加载不了项目。” 只需要打开项目配置文件*.csproj,将True 改为 False,然后可以正常加载项目,接着重新配置为正常的IIS. 您可能感兴趣的文章:System.Data.SqlClient.SqlException: 无法打开登录所请求的数据库 登录失败。System.Data.SQLite 数据库详细介绍SQL Server出现Syst
.NET Runtime 1026错误[可运行源码]
本文介绍了.NET Runtime 1026错误的解决方法。错误发生在iSmartPush.exe应用程序中,Framework版本为v4.0.30319,错误原因是未处理的异常System.Runtime.InteropServices.COMException。文章提供了详细的解决步骤:首先以管理员身份打开命令提示符,然后运行DISM.exe和sfc /scannow命令来校验和修复系统镜像。这些步骤旨在帮助用户解决因系统文件损坏或缺失导致的运行时错误。
Windows 2008 R2服务管理器刷新失败的解决方法
刷新服务器管理器时出现意外错误: 异常来自 HRESULT:0x800F0818,有关详细信息,请参阅事件日志: 诊断、事件查看器、应用程序和服务日志、Microsoft、Windows、服务器管理器、操作
ASP.Net Web应用程序与EXCEL交互时遇到的权限问题
ASP.Net Web应用程序与EXCEL交互时遇到的权限问题解决方案
使用WIA获取扫描仪数据(C#)
使用WIA获取扫描仪数据(C#),可实现扫描仪端口的连接


