wordApp.Documents.Open()获不到对象 请大神求救
bool isSucceed = false;
Word.WdExportFormat fileFormat = Microsoft.Office.Interop.Word.WdExportFormat.wdExportFormatPDF;
Word._Application wordApp = null;
if (wordApp == null)
{
wordApp = new Word.Application();
}
Word._Document wordDoc = null;
try
{
wordDoc = wordApp.Documents.Open(fileName); wordDoc.ExportAsFixedFormat(outputFileName, fileFormat);
isSucceed = true;
}
为什么WordDoc的值为空,fileName的值是存在的,权限我也设置了。
[解决办法]
从你的代码上看,都是空值啊。 能设断点吗?
[解决办法]
试试:
wordApp.Documents.Open(ref templateFile, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Visible, ref Nothing, ref Nothing, ref Nothing, ref Nothing);