C# docx to html[此命令不可用。]
我需要将word文档转换为HTML。我可以用C# docx to html[此命令不可用。],c#,html,ms-word,interop,C#,Html,Ms Word,Interop,我需要将word文档转换为HTML。我可以用doc文件来完成 但是当我使用docx作为输入时。我收到一个错误 这是我的密码 public static string DocToHtml(string path) { try { //I used Microsoft Interop v12 because this doesn't give me the Access Violatio
doc
文件来完成
但是当我使用docx
作为输入时。我收到一个错误
这是我的密码
public static string DocToHtml(string path)
{
try
{
//I used Microsoft Interop v12 because this doesn't give me the Access Violation Error.
Microsoft.Office.Interop.Word.Application _App = new Microsoft.Office.Interop.Word.Application();
Microsoft.Office.Interop.Word.Document _Doc = _App.Documents.Open(path);
//Let's save the converted document to the temp folder
string tempDocx = System.IO.Path.GetTempPath() + "_tempConvertedToHtml.html";
object _DocxFileName = tempDocx;
object FileFormat = Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatFilteredHTML;
_Doc.Convert();
_Doc.SaveAs(ref _DocxFileName, ref FileFormat);
//Close the Word interface
_Doc.Close();
_App.Quit();
path = tempDocx;
}
catch (Exception ex)
{
Console.WriteLine(ex.StackTrace);
throw ex;
}
return path;
}
哪一行给了你错误?哪一行给了你错误?