0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

C#から、Officeアプリを操作する時のメモ

Posted at

要約
・Microsoft.Office.Interop.なんたら、をusing
・DLLをさがせ
・DLLのバージョンを確認しろ
・コンパイル時にDLLをrefしろ

ソース

using System;
using Excel = Microsoft.Office.Interop.Excel;

Excel.Application excelApp = new Excel.Application();


using System;
using PowerPoint = Microsoft.Office.Interop.PowerPoint;

PowerPoint.Application pptApp = new PowerPoint.Application();

コンパイル

c:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe
/target:exe
/reference:"C:\Path\
Microsoft.Office.Interop.Excel.dll"
Program.cs

/reference:OFFICE.DLL;Microsoft.Office.Interop.PowerPoint.dll

DLLのバージョン確認

powershell (Get-Item "C:\Users\Office.dll").VersionInfo.ProductVersion

PC内のDLLの探索

c:\> dir /s OFFICE.DLL

 c:\Program Files\Microsoft Office\root\Office16\ADDINS\Microsoft Power Query for Excel Integrated\bin のディレクトリ

2022/08/19  13:15           458,544 Office.dll
               1 個のファイル             458,544 バイト
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?