OK, giờ mình đã tìm được câu trả lời, có vậy mà tối qua tìm hoài.
Cách 1:
Mã:
using System.Diagnostics;
Mã:
Process.Start("Đường dẫn đến file cần mở");
Rất đơn giản, dùng cho mọi lọai file.
Cách 2:
Add Reference: Microsoft.Office.Interop.Word
Sau đấy chèn cái này vào sự kiện:
Mã:
// Tạo một thể hiện của ứng dụng MS Word
ApplicationClass wordApp = new ApplicationClass();
// Các tham số được sử dụng trong hàm Open được hỗ trợ bởi thư viện API của MS Word
object wFileName = sSelectDirHide2 + sSelectNameHide2;
object wConfirmConversions = true;
object wReadOnly = true;
object wAddToRecentFiles = true;
object wPasswordTemplate = "";
object wRevert = true;
object wWritePasswordDocument = "";
object wWritePasswordTemplate = "";
object wFormat = WdOpenFormat.wdOpenFormatAuto;
object wVisible = true;
object wOpenAndRepair = true;
object wDocumentDirection = WdDocumentDirection.wdRightToLeft;
object wNoEncodingDialog = false;
// Nếu bạn không sử dụng thông số nào đó trong hàm Open thì sử dụng biến này
// với giá trị missing value để truyền vào cho đúng profile của hàm
object nullobj = System.Reflection.Missing.Value;
// Show cửa sổ ứng dụng Word
wordApp.Visible = true;
// Solution 1: không sử dụng các thông số không cần thiết ngoai trừ đường dẫn đến file cần mở
Document doc = wordApp.Documents.Open(
ref wFileName, ref nullobj, ref nullobj, ref nullobj,
ref nullobj, ref nullobj, ref nullobj, ref nullobj,
ref nullobj, ref nullobj, ref nullobj, ref nullobj,
ref nullobj, ref nullobj, ref nullobj, ref nullobj
);
Pallet nhựa Lâm Đồng giải pháp hoàn hảo cho nhà kho Pallet nhựa Lâm Đồng là một giải pháp đa năng và hiệu quả trong việc vận chuyển và lưu trữ hàng hóa. Trong đó, pallet nhựa Lâm Đồng không chỉ đáp...
Pallet nhựa Lâm Đồng giải pháp...