Ципихович Эндрю 1508 / 478 / 56 Регистрация: 10.04.2009 Сообщений: 8,008 |
||||
1 |
||||
Свойства файла Ворд03.05.2011, 16:52. Показов 13682. Ответов 18 Метки нет (Все метки)
Имеется скрипт для определения свойств файла Ворд:
Он выдаёт свойства файла: 1 Title 18 декабря 2001 года N 174-ФЗ Какое из этих свойств можно менять программно, перед закрытием файла, то есть процедурой АутоКлозе, чтобы потом в случае надобности его, изменённое свойство можно было считать, программно не открывая файл?? Если можно с примерами по изменению свойства и по считыванию его. Спасибо
0 |
Programming Эксперт 94731 / 64177 / 26122 Регистрация: 12.04.2006 Сообщений: 116,782 |
03.05.2011, 16:52 |
18 |
mc-black 2784 / 716 / 106 Регистрация: 04.02.2011 Сообщений: 1,443 |
||||
03.05.2011, 17:10 |
2 |
|||
Кто ж это знает. Может покопать MSDN? А вообще свойства документа можно получать (и пытаться устанавливать) при помощи вот такой конструкции:
На то есть перечисление .WdBuiltInProperty, то есть когда наберешь bp = , после этого вываливается список свойств документа Word. Там все написано словами, а не цифрами, что намнго удобней бывает.
0 |
1508 / 478 / 56 Регистрация: 10.04.2009 Сообщений: 8,008 |
|
03.05.2011, 17:42 [ТС] |
3 |
какие были 30 штук те и есть:
0 |
2784 / 716 / 106 Регистрация: 04.02.2011 Сообщений: 1,443 |
|
03.05.2011, 17:49 |
4 |
Строка 4 задает одно из свойств. Строка 5 — читает свойство и выводит в консоль. Закоментирована строка 6 — запись свойства. В данном случае ошибка не выдается даже если присваивать значение, которое потом не может быть сохранено в документе. Можно наверное только наощупь проверять путем проб и ошибок. Не все же свойства одновременно Вам нужны ждя изменений, хватит и нескольки основных, я полагаю.
1 |
Ципихович Эндрю 1508 / 478 / 56 Регистрация: 10.04.2009 Сообщений: 8,008 |
||||
03.05.2011, 18:16 [ТС] |
5 |
|||
спасибо, пока Ворд тупит, пока выложу сюда с комментариями, потом попробую
Только по поводу считывания свойства, это совсем другой должен быть макрос, и считывать с закрытого файла, как, есть пример???
0 |
Ципихович Эндрю 1508 / 478 / 56 Регистрация: 10.04.2009 Сообщений: 8,008 |
||||
04.05.2011, 19:28 [ТС] |
6 |
|||
почему происходит звук?? Потому, что свойство не изменилось, может надо другое свойство менять, какое, чтобы
0 |
2784 / 716 / 106 Регистрация: 04.02.2011 Сообщений: 1,443 |
|
05.05.2011, 17:37 |
7 |
Ну так проверь сам, ты программист или где? Что ленишься, раз знаешь как проверить? Даю ещё подсказку: меню Файл — Свойства… В окне «Свойства: Документ1» вкладка «Документ» — берешь любое из этих полей. Как они называются в перечислении констант этих полей нетрудно догадаться по переводу с английского названий констант. Как прочитать свойства полей не открывая файл в Word — зачем тебе, если тебе это действие надо проделывать макросом из Word — никакого выигрыша от этого не вижу. Это делается по идее какими-то API функциями оболочки, возможно из shell32.dll
0 |
Ципихович Эндрю 1508 / 478 / 56 Регистрация: 10.04.2009 Сообщений: 8,008 |
||||
05.05.2011, 17:57 [ТС] |
8 |
|||
вот сейчас случайно глянул два Вордовских файла в одно нажимаешь на свойства Добавлено через 12 минут
Как это свойство считать с закрытого файла, если нельзя, то с какого свойства можно считывать с закрытого файла???
0 |
2784 / 716 / 106 Регистрация: 04.02.2011 Сообщений: 1,443 |
|
05.05.2011, 18:34 |
9 |
Из листа «сводка», если файл закрыт, попробуй менять эти параметры программно из VBA. Потом их можно будет читать без полного открытия файла в Word.
0 |
1508 / 478 / 56 Регистрация: 10.04.2009 Сообщений: 8,008 |
|
05.05.2011, 18:52 [ТС] |
10 |
вижу
0 |
mc-black 2784 / 716 / 106 Регистрация: 04.02.2011 Сообщений: 1,443 |
||||
06.05.2011, 11:05 |
11 |
|||
Не там смотришь. Внимательней. Это в свойствах «закрытого» файла надо смотреть. Например в открытом ввожу на вкладке «Документ» в поле «Название» текст «qwerty» Добавлено через 12 минут
0 |
1508 / 478 / 56 Регистрация: 10.04.2009 Сообщений: 8,008 |
|
06.05.2011, 17:58 [ТС] |
12 |
как изменять, мне два дня как понятно, не понятно как считывать с закрытого файла свойства???
0 |
2784 / 716 / 106 Регистрация: 04.02.2011 Сообщений: 1,443 |
|
10.05.2011, 23:14 |
13 |
Я этого сам пока что не знаю, но уверен, до этого можно докопаться.
0 |
48 / 9 / 0 Регистрация: 29.11.2010 Сообщений: 149 |
|
21.02.2012, 12:54 |
14 |
Как вариант посмотрите здесь <Ссылка на форум>, проблемы закрытого файла это не решает, но значительно упрощает жизнь.
0 |
1702 / 189 / 19 Регистрация: 20.11.2011 Сообщений: 281 |
|
21.02.2012, 13:34 |
15 |
Не ребят, почитайте справку по CustomDocumentProperties, создавайте эти проперти и меняйте, сколько хотите.
0 |
1508 / 478 / 56 Регистрация: 10.04.2009 Сообщений: 8,008 |
|
21.02.2012, 18:26 [ТС] |
16 |
Запрещено публиковать ссылки на другие форумы уж коли так, пжл скопипастите статью, прочитаю на этом форуме
0 |
sjerj 48 / 9 / 0 Регистрация: 29.11.2010 Сообщений: 149 |
||||
28.02.2012, 18:07 |
17 |
|||
уж коли так, пжл скопипастите статью, прочитаю на этом форуме В нужной мне интерпретации, запись свойства «категории» для файла в «тихом режиме» т.е. фактически, файл открылся и сразу закрылся не раздражая нас. пример адаптированного кода:
К сожалению всю статью привести не могу, поскольку там аналог этого форума — куча постов, как их вставить сюда не знаю.
0 |
1300 / 402 / 22 Регистрация: 21.10.2011 Сообщений: 1,285 |
|
16.03.2012, 19:02 |
18 |
как изменять, мне два дня как понятно, не понятно как считывать с закрытого файла свойства??? Прежде, чем работать с документом, — нужно открыть документ.
0 |
1 / 1 / 0 Регистрация: 16.01.2014 Сообщений: 9 |
|
19.11.2015, 09:10 |
19 |
А как считать с помощью VBA разрешение по X и Y (т.е. отдельно ширину и высоту) картинки (фотографии)? Имеется директория с картинками. Нужно для каждого файла получить значение ширины и высоты в отдельных ячейках.
0 |
Формулировка задачи:
Добрый день!
Задача такая:
Формирую документ word программно из access (на основе шаблона) так:
При нажатии «Сохранить» в полученном документе в качестве названия по умолчанию подставляется то, что написано в свойствах документа в поле «Название», а хотелось бы задать свое. Задаю программно это свойство:
Название меняется, но при нажатии «Сохранить» опять показано старое значение, а изменяется оно на новое только если открыть свойство документа из меню «Файл» и там нажать ОК.
Я так понимаю, ворду нужна команда для перезагрузки значений свойств. Есть такая?
Или какие еще могут быть варианты для задания своего названия при открытии диалога сохранения?
Код к задаче: «Изменение свойств документа Word или как еще задать желаемое название при сохранении»
textual
If Set_NameDoc = True Then ' если разрешено предустановленное название App.ActiveDocument.SaveAs Environ("temp") & "TempD.doc" App.Quit False Set App = New Word.Application App.Documents.Add Environ("temp") & "TempD.doc" End If App.Visible = True AppActivate (App.Caption) Set App = Nothing
Полезно ли:
6 голосов , оценка 4.167 из 5
The problem
I’m having some trouble setting document properties using VBA in Word 2010.
I have a document containing several Heading 1
sections and I use a macro to extract a selected section (along with it’s contents) and paste it to a new document.
This part works fine, but at the end I need to set several document properties, but none of them are being set.
I’m trying to set both built-in and custom properties, but for the purpose of this question I’d like to set title, subject and, category.
I’ve created a function to set the properties I desire (as below), and VBA is throwing no error (even when I remove error handling in the function).
Does anybody know what I am doing wrong?
How the function should work
Here is a brief summary of what the function should do, but the full function is below should you find it easier to check that —
- Check to see if the property already exists
- It does and it is a
default
property- Set the default property
- Set the
PropertyTypeUsed
variable todefault
- it does and it is a
custom
property- Set the custom property
- Set the
PropertyTypeUsed
variable tocustom
- It does not exist at all
- Create a new custom property
- Set the custom property
- Set the
PropertyTypeUsed
variable tocustom
- It does and it is a
- Check whether or not a value has successfully been set
- A
default
property should have been set- Was the property set successfully?
- A
custom
property should have been set- Was the property set successfully?
- A
- Return the result
The function I believe is causing the issue
Function UpdateDocumentProperty(ByRef doc As Document, _
ByVal propertyName As String, _
ByVal propertyValue As Variant, _
Optional ByVal propertyType As Office.MsoDocProperties = 4)
'** Set the result to 'False' by default '*
Dim result As Boolean
result = False
'** A property to hold whether or not the property used is default or custom *'
Dim propertyTypeUsed As String
'** Check to see if the document property already exists *'
If PropertyExists(doc, propertyName) Then ' A default property exists, so use that
doc.BuiltInDocumentProperties(propertyName).value = propertyValue
propertyTypeUsed = "default"
ElseIf PropertyExists(doc, propertyName, "custom") Then ' A custom property exists, so use that
doc.CustomDocumentProperties(propertyName).value = propertyValue
propertyTypeUsed = "custom"
Else ' No property exists, so create a custom property
doc.CustomDocumentProperties.Add _
name:=propertyName, _
LinkToContent:=False, _
Type:=propertyType, _
value:=propertyValue
propertyTypeUsed = "custom"
End If
'** Check whether or not the value has actually been set *'
On Error Resume Next
If propertyTypeUsed = "default" Then
result = (doc.BuiltInDocumentProperties(propertyName).value = propertyValue)
ElseIf propertyTypeUsed = "custom" Then
result = (doc.CustomDocumentProperties(propertyName).value = propertyValue)
End If
On Error GoTo 0
UpdateDocumentProperty = result
End Function
Full project code
The full code for this project can be found in two Paste Bins —
- The functions
- The form
I’m not sure if it’s possible to get the code for actually creating the form (short of exporting it, but I have no where to put it), but in any case it’s very simple —
- The form —
frmChooseDocument
- The label —
lblChooseDocument
(Which New Starter document would you like to export?) - The combobox —
comChooseDocument
- The cancel button —
btnCancel
- The OK button —
btnOK
(Initially disabled)
In reality I’m using the document that houses this code as a ‘master’ document for new startes, containing detailed instructions on how to use variouse applications.
The code itself looks for Heading 1
formatted text within the document and adds them to the combobox in the form, allowing the user to select a section to export. A new document is then created and saved as a PDF.
Update
As suggested in the comments, I have checked that the type of value being set matches that of the value being passed to the function and it does.
In the case of all 3 properties described above, both the value that I am passing and the property as stored against the document are of type string
.
I’ve added a couple of lines to output the type and value where I am setting the result and all looks well, but obviously it is not!
Debug.Print "My value: (" & TypeName(propertyValue) & ")" & propertyValue
Debug.Print "Stored property: (" & TypeName(doc.BuiltInDocumentProperties(propertyName).value) & ")" & doc.BuiltInDocumentProperties(propertyName).value
Here is the output —
My value: (String)New Starter Guide - Novell
Stored property: (String)New Starter Guide - Novell
My value: (String)New starter guide
Stored property: (String)New starter guide
My value: (String)new starters, guide, help
Stored property: (String)new starters, guide, help
-
Question
-
HI..
All replies
-
Select File > Info.
On the right hand side, click Properties > Advanced Properties.
Activate the Custom tab.
Type a name, select a type, and enter a value if desired, then click Add.
Regards, Hans Vogelaar
-
I tried but doesnt show on document property list
can you try?
-
To reference the property via a DOCPROPERTY field in the document, go to the document itself (not a dialogue), press Ctrl-F9 and type ‘DOCPROPERTY test’ between the field braces (ie {DOCPROPERTY test}), then press F9 to update the field.
Cheers
Paul Edstein
[MS MVP — Word]-
Edited by
Wednesday, August 1, 2012 5:23 AM
-
Edited by
-
Hi,
Based on my research, this should be done with Microsoft Office InfoPath.
The properties that appear in the Document Information Panel can’t be changed unless you add custom properties by using a property management server or a Microsoft Office InfoPath form.
You can add some custom properties by clicking Advanced Properties in the upper left of the Document Information Panel, but the properties will not appear in the Document Information Panel or in the document itself.- Click the File ->Info->
Properties->Show Document Panel
The Document Information Panel opens above your document.
- Fill out the property information that you want to keep with your document.
Notes :
- The Required field flag appears only with properties that are bound to documents that are stored on property management servers. Built-in properties are never required for a document.
- You can add custom properties to the Document Information Panel if you are using a property management server, such as Microsoft Office SharePoint Server, and Office InfoPath.
Here’s the link to refer:
http://office.microsoft.com/en-us/help/add-property-information-to-a-document-HA010163766.aspx
The link is for Word 2007. I have changed the steps in the above information for Word 2010.
The following link is about “Design a Document Information Panel by using InfoPath”, but it is also applies to InfoPath 2007, you can refer:
http://office.microsoft.com/en-us/infopath-help/design-a-document-information-panel-by-using-infopath-HA010201967.aspx
Jaynet Zhang
TechNet Community Support
- Click the File ->Info->
-
Hi Jaynet,
Many of us have been creating & referencing custom document properties since way before InfoPath existed. There is no need to use InfoPath to do so now.
Cheers
Paul Edstein
[MS MVP — Word]-
Edited by
macropodMVP
Wednesday, August 1, 2012 6:44 AM
-
Edited by
-
Hi paul,
Not working
-
Edited by
MGerio
Wednesday, August 1, 2012 7:13 AM
-
Edited by
-
Your ‘Error! Unknown document property name’ message suggests you have mis-typed the property name, or you’re using it in a document that doesn’t have the ‘test’ document property.
The bookmark error messages suggest you’re trying to reference an non-existent bookmark — document properties are not bookmarks.
Cheers
Paul Edstein
[MS MVP — Word] -
-
Your DOCPROPERTY field should look like what I posted:
{DOCPROPERTY test}
Simply having { test } creates nothing more than a bookmark reference. That ain’t gonna fly…
Because it’s a custom property, all you’ll see in the document after updating is the field’s value:
test
Cheers
Paul Edstein
[MS MVP — Word] -
Create a custom document property:
To insert a DOCPROPERTY field, either use Insert > Quick Parts > Field…, or use Ctrl+F9 as described by macropod.
Regards, Hans Vogelaar
-
-
That looks about right.
Cheers
Paul Edstein
[MS MVP — Word] -
-
All document properties on the ‘Custom’ properties tab are editable/customizable. To
create or change a property, you access it via the dialogue box or via vba. To
reference them, you use DOCPROPERTY fields or vba.
Cheers
Paul Edstein
[MS MVP — Word] -
Can document custom property be inserted, edited and look like this?
-
Can document custom property be inserted, edited and look like this?
No, not as far as I know. Edit in the Document Properties dialog, display through a DOCPROPERTY field.
Regards, Hans Vogelaar
-
How sad..
however… I noticed that when i close the word program and reopen a new instance, my custom Doc property are gone.
But on the document itself where i put my custom doc property, items are retained.
why is that so?
-
Edited by
MGerio
Thursday, August 2, 2012 5:21 AM
-
Edited by
-
Custom document properties are stored, as the name indicates, in the document (or template). They will not be available elsewhere.
Regards, Hans Vogelaar
-
Marked as answer by
Jaynet Zhang
Tuesday, August 7, 2012 1:43 AM -
Unmarked as answer by
MGerio
Saturday, August 18, 2012 4:59 AM
-
Marked as answer by
-
There are now two sorts of «Custom Document Property» in Word:
The old sort, where you create/maintain them in the «Advanced Properties»->Custom dialog pane, and insert them using
DOCPROPERTY fields. These are not displayed in the «Document Property» drop down you display in your original post.The new sort, which are the sort that Jaynet Zhang describes. These are typically, but not necessarily, related to columns created in a SharePoint library. When a document is opened from Sharepoint, Sharepoint inserts information about the names and values
of these columns in Word. Their names then appear in the Document Property dropdown. When you insert one of the Properties from this dropdown, Word inserts a
Content Control that is linked to the value of the property. However, not all the names in that dropdown are related to SharePoint properties — some are «Builtin» Properties such as Author, and others come from a special set of «Cover Page Properties»
introduced in Word 2007 (Company fax, etc.)Arguably the first sort of Property is the «true» «Custom Document Property», but since the second sort are also described as «Document Properties» and can be user-created (by a SharePoint user), and do not seem to have a well-established name, people not
unnaturally refer to them using the same name as the first sort. Sometimes they are referred to as «Server Properties»Using VBA or other coding techniques, it is theoretically possible to set up «Server Properties» without either Sharepoint or InfoPath by creating some chunks of «Custom XML» (another reason why the word «Custom» is sometimes used for these properties).
However, without the server present, these properties do not work in quite the same way as the «real thing» — e.g., with the server present, there is more validation.The thing about «Server Properties» and the other properties on the dropdown is that each Content Control is linked to a specific property held in the document’s XML. If you have more than one content control linked to the same property value, when the property
value is updated, the value in each of the linked Content Controls is updated automatically. That does not happen with DOCPROPERTY fields, and unfortunately it isa. not possible to link a Content Control directly to the value of the old type of Custom Property.
b. either not possible, or not easy, to include DOCPROPERTY fields in the dropdown.
So which type of control you choose depends on what you are trying to achieve, and the environment you are working in.
Peter Jamieson
-
Edited by
Peter Jamieson
Thursday, August 16, 2012 8:32 AM
content control->custom property in point (a) -
Proposed as answer by
Hunter.CHEN
Wednesday, March 2, 2016 4:56 AM
-
Edited by
-
Thanks Peter. Very informative.
Cheers
Paul Edstein
[MS MVP — Word] -
I Wonder..
Engineer is not listed in default document property but I received a document with this doc property:
How Do I create this?
-
Let’s step back.
There are several ways to show «repeating data» in Word documents. Greg Maxey documents most of them at
http://gregmaxey.mvps.org/word_tip_pages/repeating_data.htmlYou may find it useful to have a look around his site, particularly this page:
http://gregmaxey.mvps.org/word_tip_pages/mapped_content_controls.htmlWhat you are showing is a Content Control with some text in it. The text might or might not be the value of a «document property».
You can make your own Content Controls in the Developer Tab (you can enable it in Word Options). You can modify the title (in this case «engineer») using the Properties button in the Developer tab. And you can type some text into the Content Control.
At that point you have a Content Control containing some text. I wouldn’t personally call that a «document property,» because to me a property is something that can exist independently of what you put on the document surface. In the case of Word, it is also
possible to insert copies of the value of most (if not all) types of property on the document surface. For example, you can insert copies of the value of the built-in Author property using an { AUTHOR } field. Others here have described the mechanism you can
use with DOCPROPERTY fields.To do that with Content Controls, you have at least to link the Content Control with a piece of data stored outside the document surface. If someone has done that in this case, you ought to be able to do the following:
a. copy/paste a copy of the Content Control into your document
b. edit the text «Nikoli Tesla» in one of the Content Controls (CCs)
c. click somewhere outside the control.
If the content of the other control changes, then the two controls are linked to a piece of data held outside the document surface. In this case, that might have been achieved in a number of different ways, e.g.
1. someone might have inserted one of the standard Document Properties (e.g. using insert->Quick Parts->Document Property and selecting «Comments»), then modified the Title of the property to be «engineer.» In that case, modifying the value of
the builtin Comments property would cause the text in the CC to change and vice versa. If so, the document creator has not created a
new property, just the title used to display it in one part of their document.2. someone might have created and inserted a custom XML part containing an element or attribute that contains the text «Nikoli Tesla», created and inserted a Content Control with title «engineer», and linked that control to the XML element/attribute.
At least (2) and probably (1) is/are described in the Mapped Content Controls article referenced above.
3. someone might have created the document in a Sharepoint library that has a column defined with the display name «engineer». In that case (unlike the other two cases above), an «engineer» property would probably (but not necessarily) be present in
the drop down list of Document Properties. These types of properties are the ones sometimes described as «Server Properties», and are not currently covered by Greg in his article (for one thing, they have a more complex XML representation).Whether you regard all those things (1), (2), (3) as Document Properties is arguable, really. They are obviously «properties of a document». The main sense in which (1), (3) and the old «Custom Document Properties» differ from (2) is that the way they are
stored is defined in the ECMA/ISO standards documents for Word .docx type documents.
Peter Jamieson
-
Proposed as answer by
Hunter.CHEN
Wednesday, March 2, 2016 4:56 AM
-
Proposed as answer by
-
check this link this may help you out
http://superuser.com/questions/285256/word-2010-how-to-reference-custom-document-properties
-
Its awkward.
Seems a plain document property name insertion/customization doesn’t have a simple execution.
Does it have to take a brilliant programmer to have an «add», «modify» or «rename» document property option in Microsoft Word 2010?
-
Edited by
MGerio
Wednesday, August 22, 2012 2:47 AM
-
Edited by
-
@maan
Link is same as instruction in earlier replies.
-
Its awkward.
Seems a plain document property name insertion/customization doesn’t have a simple execution.
Does it have to take a brilliant programmer to have an «add», «modify» or «rename» document property option in Microsoft Word 2010?
Word already has the facility to add/modify/delete a Document Property. You do that via the processes already discussed.
What you seem to not recognise is that what you’re showing is not the Document Property itself but, at most, a reference to it. Of course, if you use a Content Control for maintaining the details, you could use a ContentControlOnExit macro to update the
Document Property. You could even write code to add/delete such Document Properties via Content Controls, but I wouldn’t recommend it.
Cheers
Paul Edstein
[MS MVP — Word] -
What you seem to not recognise is that what you’re showing is not the Document Property itself but, at most, a reference to it. Of course, if you use a Content Control for maintaining the details, you could use a ContentControlOnExit macro to update the
Document Property. You could even write code to add/delete such Document Properties via Content Controls, but I wouldn’t recommend it.
Cheers
Paul Edstein
[MS MVP — Word]May I join this discussion by asking why nobody
out there has written the code necessary to add, edit, and delete Document Properties via Content Controls? This appears to be
exactly what MGerio asked in the post that he added to this thread on Wednesday, August 1st, 2012 at 12:09 AM in clarifying his original question. In fact, I need the code too because I need to link a ‘Teacher’ content control in the first
page header of a short report that I am writing to a custom ‘Teacher’ document property associated with it because MLA style requires this. Features like this should reside within Word’s standard UI!P.S.: I hope that the developers of Office 2013 are looking at this thread.
-
I pointed to Greg Maxey’s site which has a lot of info on this general subject, but a more specific reference that may help you is
http://www.gmayor.com/BookmarkandVariableEditor.htm
Beyond that, one way of starting to think about the answer to your own question is to list the barriers that prevent you from creating the software you need. Then consider how much more difficult it might be to create something that is easy and reliable
for other people to use.
Peter Jamieson
-
Hi everybody,
i have a similar issue i’ve been struggling with for quite a long time now, i will try to give you as detailed information as possible, so please excuse my excessive writing.
I try to find a way to (automatically) enter user information (possibly from our AD) to a .docx concept template into fields or document properties or whatever possible. all of the fields reside on the front page, some of them are placed in the header and footer
of the document.Up to now, my workaround is that i simply inserted document properties and customized them with different titles, tags and styles. the only problem is, that the user has to fill in all of them including going into the header and footer sections to reach some
of the properties.This is what i either want to relocate to the properties section on the info tab, before working in the document, or that i want to be filled out automatically with user information from AD (of course excluding properties that only apply to the actual document
like customer, project and so on).I want to keep the document free from macros and add-ins whenever possible.
However, i did try vba and even tried some weird add-in and played around quite extensively with document properties and fields, but nothing worked for me the way that i wanted.I think it has to be somehow possible to create custom fields/document properties/whatever on the front page (including header & footer) where then, when opening the document, the first thing the user should do would be typing in his or her properties on
the file tab —> info.
There the user should be able to also fill in customized properties like «customer», «project name»or «type of document» without having to create custom properties each time they open the template document.Is that possible in any way? And if so, can this be done with just fields or with document properties? i’d like to have a different style attached to each property. For example, «customer» is big and bold, whereas telephone number and email are plain and simple.
I’m no expert in directory services and also not in Word but i wonder why there’s no easier built-in way to reference customized document information or any possibility to automatically retrieve user information from Active Directory. I’m sure that lots of
customers would be pleased to solve this without vba or third party add-ins..Again, sorry for the letter, i hope someone can share some ideas on this.
Thanks,
Stufe -
Dear macropod,
This is great option but, for some reason, this «DocProperty» acts as standard «CustomProperty» which is limited to 255 characters.
If I use one of the «quick parts»—> «Document properties» such as «Manager, I can fill this property with Unlimited number of characters and also put some «Enters»…
Is there any option to define this DocProperty to be able to filled with more than 255 characters?
Thanks,
Orion Lidji..
-
AFAIK, no — the limit is 255 characters.
Cheers
Paul Edstein
[MS MVP — Word] -
Hi guys,
2 years later, and I’m trying to achieve exactly this. Thanks for your answers Peter, very interesting.
Based on your posts and your link (http://gregmaxey.mvps.org/word_tip_pages/mapped_content_controls.html), I understand that it is possible to bind a Content Control only
to a builtin Document Property. It is not possible to bind them to a Custom Document Property.One question: does anyone know if this has improved in Word 2013? Because the Content Control is so much userfriendly than {docproperty}/F9/and so on… And it is a little complex if I must have a Sharepoint server to be able to add metadata to my Word document…
-
As far as I know the situation is the same in 2013, i.e. the main differences in that version are to do with other aspects of content controls (new mapping UI, mapping of rich text controls, repeating groups).
Peter Jamieson
-
Ok thanks for your answer!
-
This is an excellent thread. I love how painstakingly and patiently mgerio walks through all replies and leads back to the original issue, time and time again — sometimes even using several replies. He will not be deterred or allow the thread to be repurposed
or construed off topic! I love the informative and valuable replies by everyone, including Peter Jamieson (despite some oddities, IMNSHO).Great summary of the need by RandomDSDevel. This is a could-have-been-fantastically-awesome-and-usable feature that stopped half-way, half-baked. Just opening that Quick Parts drop down makes me sad thinking of how good it could have been, the way I and
many others thought it would work the first time we tried it out — so close… so close… -
hi,
i am not able to enter more than 255 character in value field. if any settings available let me know pls..
-
hi,
i am not able to enter more than 255 character in value field. if any settings available let me know pls..
As has been pointed out in this thread, the maximum length of a custom document property is 255 characters. This cannot be changed.
Regards, Hans Vogelaar (http://www.eileenslounge.com)
-
This one provides the most useful tool on the content control. Thanks a lot
-
Hi Hans
Re: Custom Quick Parts ~ Do you know how the values are seen by other applications that use MetaData? Do these custom quick parts variables show up?
I’d like to prepare files to be uploaded into a DMS, by creating a smart coversheet that contains meta data.
The QuickParts are a great start but they don’t cover all the basics. I was using Sharepoint as a DMS, but not anymore, the IT guys are thinking of procuring something else. Thank you very much for any direction you can give. -
I am not Hans, but (a) different types of property are stored in different ways, and (b) there are at least three possible ways to extract them, at least from a .docx:
— Using the Word object model or .NET Interop, you can probably extract most, if not all of them, at least on Windows Word
— You may still be able to extract the builtin properties and old-style Custom Document Porperties using the dsofile DLL (have a look around)
— By digging around in the individual XML parts that make up a .docx fileThere may also be third-party libraries that will do those jobs for you, but I am not familiar with any of them.
Using the Word object model, you can get at
— the traditional built-in properties via a Document’s BuiltInDocumentProperties property— the traditional custom properties via a Document’s CustomDocumentProperties property
— the «Cover Page Properties» by identifying the Custom XML Part that contains those properties and using XPath or other code to retrieve individual values.
— *most* SharePoint type properties via a Document’s ContentTypeProperties collection property.
— (if you take the view that Word Document Variables are «properties», you can get them via the Document’s Variables collection).
The dsofile DLL is a Win32 DLL that let you retrieve builtin properties and old-style custom document properties. I don’t know what its status is now, and I doubt if it was ever expanded to include any other property types.
If you want to get them straight from the .docx, a .docx is a .zip that contains its own file structure. You can unzip it and look at the individual .xml files, or use an API such as the .NET packaging API or the Office Open XML (OOXML) API to access the content.
In principle, you have to discover the existence and location of each part using the [Content_Types].xml file in the .docx. In practice, documents created by Word always put the parts in the same folder structure within the file. But the broad-brush picture
is that
— the built-in properties are stored in 2 XML parts: core.xml and app.xml.
— Old-style Custom document properties are stored in custom.xml.
— Cover Page properties are stored in an itemsn.xml part in the CustomXml folder (e.g. items1.xml)
— Sharepoint properties are stored in one or more itemsn.xml parts in the CustomXml folder, and a set of Sharepoint-generated XML schemas is stored in a nother part.
— Document Variables are stored in the settings.xml part.If you have also to deal with .doc format documents, you can access old-style properties as above. I forget what the situation as far as newer property types are concerned — AFAICR Sharepoint metaproperties are stored as old-style Custom-Document properties.
Your best bet with .docs is probably to open them in interop, save them as .docx format, and use those to discover properties (unfortunately, that will change some of the date/time ones), even if you need to store the .doc rather than the .docx. In principle,
it is possible to examine a .doc programmatically (that’s obviously what non-Microsoft converters do, so you may find useful libraries out there).
Peter Jamieson
-
HI..
What are shown here are not, exactly, document properties, I think. They are mapped content controls, for the most part mapped to document properties. You cannot add to this list or subtract from it. You can change the names of the properties. See Greg Maxey’s
Repeating Data for information on how.The only one that I know is not a traditional document property that can be displayed with the DocProperty field is Abstract.
Edit: Peter examines all of these in his spreadsheet. Abstract is not the only one in the document property list that is not a content control linked to a «document property» as that term has been used in the past. They are all mapped content controls
and that does make them useful.
Charles Kenyon Madison, WI
-
Edited by
Charles Kenyon
Thursday, March 10, 2016 2:52 PM
-
Edited by
-
Charles:
The items on the list will indeed insert content controls mapped to Document Properties, except for 5 which are mapped to a Custom XML Part containing Cover Page Properties, which is a namespace «known to» Word.
AFAIK the only way to get anything else into the list is either to create Document Library/List columns in Sharepoint, and download adocument from that library. At that point, Sharepoint generates some more Custom XML Parts that (a) describe the metadata it
has inserted (in the form of a few XML Schemas) and (b) contain the data. Word also recognises that stuff and generates new entries for the dropdown. Such data can also appear in the «Server Properties Document Information Panel», that is (or was
— AIUI it has gone in Word 2016, but I haven’t looked) a pane displayed by some InfoPath code, and accessed through a Document’s «ContentTypeProperties» collection. SOme of my other posts in this conversation touch on some of these subjects.Strictly speaking, you do not need SharePoint to do that — as long as you create Custom XML Parts with the appropriate structures, Word will add entries to the list. But I do not think it can be recommended because of the issue of what happens if, for example,
you create all your own SharePoint property data, then actually upload the document to a SharePoint folder with different property data.I don’t think Greg and Graham have ever (publicly) touched on the SharePoint side of things, but I am not particularly up-to-date with their material. As for the standard and cover page properties, they must have developed a list when developing one of their
utilities. You might find my own list useful — it’s temporarily athttps://www.dropbox.com/s/zt062h1i1hgwcbc/WordCoreExtendedCoverPageProperties.xlsx?dl=0
and demonstrates a number of anomalies. I doubt if it is error-free!
Peter Jamieson
-
Proposed as answer by
Charles Kenyon
Thursday, March 10, 2016 1:17 PM
-
Proposed as answer by
-
Thank you Peter. Great Answer.
-
Thank you for sharing this Peter.
Greg, in his Repeating Data page notes that it is possible to relabel these using the content control properties. That works very well if you want to do a quick and dirty mapped content control in a document or template. Here is a screenshot using a renamed
Category document property.I wish very strongly that MS had not mixed up a bunch of stuff and put it under the label «Quick Parts.» What is done, is done.
Charles Kenyon Madison, WI
-
A content control inserted using Quick Parts > Document Property > Author will look like that. A DocProperty field is what is described by Paul Edstein. This is an instance of Microsoft using the same term to describe related but different features.
Some of the content controls inserted using Quick Parts > Document Property use document properties, others do not.So, the field {DocProperty Author} will reflect the content put in the Content Control. It will also show up if you look at the document properties pane. On the other hand, the Content Control for Abstract will not be reflected in any DocProperty field nor
does it show up in the Document Properties pane.See the post by Peter.
Charles Kenyon Madison, WI
-
Can document custom property be inserted, edited and look like this?
No, but as explained in Greg Maxey’s
Repeating Data (Populating Multiple Like Fields) these content controls inserted through Quick Parts > Document Property can be retitled and repurposed. Once you do that, you can copy it to another part of your document and it will replicate the content
using the same title. The name in the drop-down list, though, will not change. If you change the title of Company to «Client» a copy of that content control will show the title «Client» but it will still be Company in the drop-down.
Charles Kenyon Madison, WI
-
I Wonder..
Engineer is not listed in default document property but I received a document with this doc property:
How Do I create this?
This is not a document property, but a Content Control. It may or may not be «mapped» to an XML node.
Word Content Controls
Charles Kenyon Madison, WI
-
hi,
i am not able to enter more than 255 character in value field. if any settings available let me know pls..
The maximum length of a custom document property is 255 characters. The maximum length of a DocProperty field result appears to be the same. I do not know of a maximum length for a content control inserted using Quick Parts > Document Property. I have
had it exceed a page in length. When that content control is inserted in another place, it holds all the original content whether inserted through the drop-down or through copy and paste.Using the Category content control from the Document Property list in Quick Parts I added a page of material that was reflected in the Category property on the Document Properties pane. However, the field {DocProperty Category} only gave 255 characters from
it.Again, Microsoft is using the term «Document Property» to refer to different Word features. The Quick Part refers to a Content Control that may be related to a document property.
Charles Kenyon Madison, WI
- FINAL
- Начинающий
- Сообщения: 18
- Зарегистрирован: 14.12.2005 (Ср) 19:02
- Откуда: Казань
А есть ли способ изменить свойство документа Word?
Проблема в следущем:
Необходимо написать макрос, который будет открывать некоторые документы Word, чтобы изменить номер редакции (одно из свойств документа, генерируется автоматически, увеличивается на единицу после каждого сохранения). Этот пункт якобы доступен для редактирования вне Word, когда открываем свойства файла (вкладка Сводка, строка редакция), а в Word’е его менять нельзя. Программно поменять через
- Код: Выделить всё
ActiveDocument.BuiltInDocumentProperties(wdPropertyRevision).Value
у меня тоже не получилось . Может, кто знает способ?
- Gloom
- Бывалый
- Сообщения: 200
- Зарегистрирован: 23.11.2004 (Вт) 15:57
- Откуда: СПб
Gloom » 28.12.2005 (Ср) 11:29
ИМХО, это свойство через интерфейсы автоматизации Word изменить нельзя. В библиотеке dsofile.dll оно также read-only.
Можно попробовать писать прямо в FileSummaryInfo, однако на VB это будет весьма затруднительно, ибо необходимые в этом случае интерфейсы IPropertySetStorage, IPropertyStorage не являются Automation совместимыми…
Вернуться в VBA
Кто сейчас на конференции
Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 1