Страница 1 из 1
Получить свойства файла xls
Добавлено: 21 ноя 2008, 06:50
RomaS
Добрый день!
Вопрос в следующем: Нужно получить свойства файла эксель - дата последнего вывода на печать. остальные свойства получил так:
Код: Выделить всё
Sub svoistva_faila() ' образец получения значений свойств
MsgBox ("nazvaniye " & ActiveWorkbook.Title & vbNewLine _
& "tema " & ActiveWorkbook.Subject & vbNewLine _
& "autor " & ActiveWorkbook.Author & vbNewLine _
& "kluch slova " & ActiveWorkbook.Keywords & vbNewLine _
& "comments " & ActiveWorkbook.Comments)
End Sub
Re: Получить свойства файла xls
Добавлено: 21 ноя 2008, 13:31
Aent
Вы будете смеяться но таки
Код: Выделить всё
Debug.Print ActiveWorkbook.BuiltinDocumentProperties("Last Print Date") 'Дата и время последней печати документа
Re: Получить свойства файла xls
Добавлено: 22 ноя 2008, 06:59
Naeel Maqsudov
А в русском и английском Офисах этот макрос сработает одинаково?
Помнится в рускос Офисе названия встроенных свойств надо было указывать на русском, т.е. так, как они видны в Файл/Свойства...
Re: Получить свойства файла xls
Добавлено: 22 ноя 2008, 12:56
Aent
Это же определённые в объектной модели константы.
У меня в русском 2003 SP3 работает.
Напротив, имена типа "Автор" не понимаются.
Да и в HELP читаем:
BuiltinDocumentProperties Property
See AlsoApplies To [url=mk:@MSITStore:C:\Program%20Files\Microsoft%20Office\OFFICE11\1049\VBAXL10.CHM::/html/xlproBuiltinDocumentProperties1.htm#example]Example[/url] Specifics
Returns a [url=mk:@MSITStore:vbaof11.chm::/html/ofobjDocumentProperties1.htm]DocumentProperties[/url] collection that represents all the built-in document properties for the specified workbook. Read-only.
Remarks
This property returns the entire collection of built-in document properties. Use the Item method to return a single member of the collection (a DocumentProperty object) by specifying either the name of the property or the collection index (as a number).
You can refer to document properties either by index value or by name. The following list shows the available built-in document property names:
01 Title
02 Subject
03 Author
04 Keywords
05 Comments
06 Template
07 Last Author
08 Revision Number
09 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)
(Номера проставил я - Aent)
Container applications aren’t required to define values for every built-in document property. If Microsoft Excel doesn’t define a value for one of the built-in document properties, reading the Value property for that document property causes an error.
Because the Item method is the default method for the DocumentProperties collection, the following statements are identical:
BuiltinDocumentProperties.Item(1)BuiltinDocumentProperties(1)
Но если есть какие то сомнения в совместимости, используйте числовой индекс элемента коллекции
Код: Выделить всё
debug.print "Last Print Date: " & ThisWorkbook.BuiltinDocumentProperties(10)
cобственно дата (без времени) естественно получается так
Код: Выделить всё
debug.print "Last Print Date=" & Left$(ThisWorkbook.BuiltinDocumentProperties(10),10)
Re: Получить свойства файла xls
Добавлено: 26 ноя 2008, 13:39
RomaS
Спасибо, а как получить упомянутые свойства у другого документа, не открывая его?
Re: Получить свойства файла xls
Добавлено: 26 ноя 2008, 22:12
Aent
RomaS, смотрите:
http://support.microsoft.com/?kbid=224351
И более подробно:
http://www.cpearson.com/Excel/DocProp.aspx
dsofile.dll нуждается в предварительной регистрации
%SYSTEMROOT%\system32\regsvr32.exe %SYSTEMROOT%\system32\dsofile.dll
( в предположении, что вы скопировали
dsofile.dll в system32)