◆Book のプロパティを取得する / 設定する
ブックのプロパティの取得には、 BuiltinDocumentProperties プロパティを
使用します。
取得できるプロパティは、作成者や会社名などです。
最後に一覧表を載せてあります。
各プロパティには、インデックス番号が割り振られていて、合計30種類あります。
この中には、他の Office アプリケーションで使用しているプロパティもあるので、
Excelですべて使用されているわけではありません。
サンプル example29 を載せてあります。
Sub GetDocumentProperty()
Dim i As Integer
Dim Object_Book, Caption_String As String
SelectInit_Book_or_Sheet = 0
Caption_String = "プロパティを取得するWookbookの選択"
Object_Book = Select_Book_or_Sheet(Caption_String)
If SelIndex = -1 Then
End
End If
On Error Resume Next
For i = 1 To 30
Range("A" & Format(i)) = Workbooks(Object_Book). _
BuiltinDocumentProperties(i).Name
Range("B" & Format(i)) = Workbooks(Object_Book). _
BuiltinDocumentProperties(i)
Next
End Sub
BuiltinDocumentProperties の対象は、Workbook オブジェクトですが、
Workbook オブジェクトは開いてあるのが前提です。
Last author などは、プロパティを変更しても、bookを保存するときに
Excelが書き換えてしまうので、設定・変更しても意味がありません。
設定・変更する項目を吟味してお使いください。
Sub SetDocumentProperty()
Dim i As Integer
Dim Object_Book, Caption_String As String
SelectInit_Book_or_Sheet = 0
Caption_String = "プロパティを設定するWookbookの選択"
Object_Book = Select_Book_or_Sheet(Caption_String)
If SelIndex = -1 Then
End
End If
For i = 1 To 30
Workbooks(Object_Book).BuiltinDocumentProperties(i) = _
Range("B" & Format(i))
Next
End Sub
Function Select_Book_or_Sheet(Caption_String) As String
SelIndex = -1
UserForm1.Caption = Caption_String
UserForm1.Show
If SelIndex = -1 Then
Select_Book_or_Sheet = ""
Else
If SelectInit_Book_or_Sheet = 0 Then
Select_Book_or_Sheet = Workbooks(SelIndex).Name
Else
Select_Book_or_Sheet = Sheets(SelIndex).Name
End If
End If
End Function
プロパティの一覧
| Index | プロパティ名 |
| 1 | Title |
| 2 | Subject |
| 3 | Author |
| 4 | Keywords |
| 5 | Comments |
| 6 | Template |
| 7 | Last author |
| 8 | Revision number |
| 9 | Application name |
| 10 | Last print date |
| 11 | Creation date |
| 12 | Last save time |
| 13 | Total editing time |
| 14 | Number of pages |
| 15 | Number of words |
| 16 | Number of characters |
| 17 | Security |
| 18 | Category |
| 19 | Format |
| 20 | Manager |
| 21 | Company |
| 22 | Number of bytes |
| 23 | Number of lines |
| 24 | Number of paragraphs |
| 25 | Number of slides |
| 26 | Number of notes |
| 27 | Number of hidden Slides |
| 28 | Number of multimedia clips |
| 29 | Hyperlink base |
| 30 | Number of characters (with spaces) |