2019-08-31
因為使用 Microsoft.Office.Interop.Word,電腦中一定要安裝 Word 付費商業版本才行,Viewer 版不行。
新增說明文字 |
Form1.cs
using Microsoft.Office.Interop.Word; using System; using System.Windows.Forms; namespace WindowsFormsApp2 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Button1_Click(object sender, EventArgs e) { var word = new Microsoft.Office.Interop.Word.Application(); word.Visible = false; string filePath = "C:\\Temp\\Test2.doc"; string filePath2 = "C:\\Temp\\Test2.htm"; var wordDoc = word.Documents.Open(FileName: filePath, ReadOnly: false); wordDoc.SaveAs2(FileName: filePath2, FileFormat: WdSaveFormat.wdFormatFilteredHTML); wordDoc.Close(); button1.Text = "ok"; } } } |
(完)
沒有留言:
張貼留言