気になる質問をクリップする
クリップした質問は、後からいつでもMYページで確認できます。
またクリップした質問に回答があった際、通知やメールを受け取ることができます。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。

回答4件
0
Spire.Docでファイルのプロパティを簡単に取得することができるようです。
Document doc = new Document(); doc.LoadFromFile("Set_Properties.docx"); //プロパティを取得 Console.WriteLine(("_タイトル: " + doc.BuiltinDocumentProperties.Title)); Console.WriteLine(("サブタイトル: " + doc.BuiltinDocumentProperties.Subject)); Console.WriteLine(("作成者_: " + doc.BuiltinDocumentProperties.Author)); Console.WriteLine(("管理者: " + doc.BuiltinDocumentProperties.Manager)); Console.WriteLine(("会社: " + doc.BuiltinDocumentProperties.Company)); Console.WriteLine(("分類: " + doc.BuiltinDocumentProperties.Category)); Console.WriteLine(("キーワード: " + doc.BuiltinDocumentProperties.Keywords)); Console.WriteLine(("コメント: " + doc.BuiltinDocumentProperties.Comments)); Console.Read();
投稿2020/11/25 05:38

退会済みユーザー
総合スコア0
0
カスタムタブは過去のOffice系ドキュメント用のプロパティだったかと思います。
WordやExcelで別々に開いて処理する方法しかわかりませんが取得は簡単です。
以下、WordとExcelの例
c#
1using System; 2 3namespace teraCLI 4{ 5 class Program 6 { 7 static void Main(string[] args) 8 { 9 var excel = new Microsoft.Office.Interop.Excel.Application(); 10 excel.Visible = false; 11 var ex = excel.Workbooks.Open(@"c:\temp\test.xls"); 12 DisplayCustomProperty(ex); 13 excel.Workbooks.Close(); 14 excel.Quit(); 15 16 var word = new Microsoft.Office.Interop.Word.Application(); 17 word.Visible = false; 18 var doc = word.Documents.Open(@"c:\temp\test.doc"); 19 DisplayCustomProperty(doc); 20 word.Documents.Close(); 21 word.Quit(); 22 Console.ReadKey(); 23 } 24 25 private static void DisplayCustomProperty(dynamic officeObject) 26 { 27 if (officeObject != null) 28 { 29 dynamic properties = officeObject.CustomDocumentProperties; 30 foreach (dynamic p in properties) 31 { 32 Console.WriteLine(p.Name + " " + p.Value); 33 } 34 } 35 } 36 } 37} 38
※Microsoft Excel "バージョン" Object Library
やMicrosoft Word "バージョン" Object Library
といったCOMをインポートする必要があります。
投稿2015/09/16 02:09
総合スコア3541
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。

0
参照設定の追加でCOMの"Microsoft Shell Controls And Automation"を追加します。
これによりShell32のAPIが使えるようになります。
ファイルのプロパティ取得を行いたいCSファイル内で using Shell32; を記載。
string dir = @"c:\tmp"; string file = @"hoge.xls"; ShellClass shell = new ShellClass(); Folder folder = shell.NameSpace(dir); FolderItem item = folder.ParseName(file); for (int i = 0; i < 1000; i++) { string name = folder.GetDetailsOf(item, i); if (string.IsNullOrEmpty(name)) continue; Debug.WriteLine(i + ": " + name); }
このようなコードで属性が取得できます。
投稿2015/09/09 10:14
総合スコア241
0
検索してみると、こんな方法でできるようです。
投稿2015/09/09 07:10

退会済みユーザー
総合スコア0
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。

退会済みユーザー
2015/09/09 07:56

退会済みユーザー
2015/09/16 03:14

あなたの回答
tips
太字
斜体
打ち消し線
見出し
引用テキストの挿入
コードの挿入
リンクの挿入
リストの挿入
番号リストの挿入
表の挿入
水平線の挿入
プレビュー
質問の解決につながる回答をしましょう。 サンプルコードなど、より具体的な説明があると質問者の理解の助けになります。 また、読む側のことを考えた、分かりやすい文章を心がけましょう。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。