Docproperty word как использовать

На чтение 2 мин Опубликовано 15.10.2015

Вставляем свойства в документ Word

В прошлых статьях мы показывали, как настраивать дополнительные свойства и создавать пользовательские свойства в документе Word. Эти свойства можно вставить при помощи экспресс-блока Поле (Field). Что полезно, когда есть слова, фразы или значения, которые часто используются в документах.

Если слово, фразу или значение, которые многократно используются в документе, планируется изменять в будущих редакциях этого документа, то использование встроенного или пользовательского свойства будет весьма полезным. Вам достаточно изменить значение свойства только в одном месте, чтобы оно изменилось сразу во всём документе.

Чтобы вставить значение встроенного или пользовательского свойства, поставьте курсор в то место, куда его нужно вставить, и откройте вкладку Вставка (Insert).

Примечание: При вставке пользовательского свойства в документ, вставлено будет только его значение. Если Вы хотите дополнить (расшифровать) значение именем свойства, введите нужный текст прежде, чем вставлять само значение.

Вставляем свойства в документ Word

В разделе Текст (Text) вкладки Вставка (Insert) нажмите кнопку Экспресс-блоки (Quick Parts).

Примечание: Подписи этих кнопок могут не отображаться, когда окно Word открыто недостаточно широко. Если Вы не видите подпись кнопки, найдите иконку, указанную курсором на изображении ниже.

Вставляем свойства в документ Word

В появившемся меню нажмите Поле (Field).

Вставляем свойства в документ Word

В выпадающем списке Категории (Categories) выберите О документе (Document Information).

Вставляем свойства в документ Word

В списке Поля (Field names) кликните по DocProperty. В разделе Свойства поля (Field Properties), который расположен по центру диалогового окна, под заголовком Свойство (Property) появится список всех доступных свойств документа (как встроенных, так и добавленных Вами). Выберите из списка пользовательское свойство, которое хотите добавить в документ, и нажмите ОК.

Вставляем свойства в документ Word

Значение будет вставлено туда, где находится курсор.

Вставляем свойства в документ Word

Изменив значение пользовательского свойства, необходимо обновить поля, вставленные в документ, чтобы они отобразили это изменение. Для этого нужно выделить все поля в документе (или полностью весь документ) и нажать клавишу F9.

Оцените качество статьи. Нам важно ваше мнение:

  • 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

  • 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.

    1. Click the File ->Info->
      Properties->Show Document Panel

    The Document Information Panel opens above your document.

    1. 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

  • 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

  • Hi paul,

    Not working

    • Edited by
      MGerio
      Wednesday, August 1, 2012 7:13 AM

  • 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

  • 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

  • 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 is

     a. 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

  • 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.html 

    You may find it useful to have a look around his site, particularly this page:
    http://gregmaxey.mvps.org/word_tip_pages/mapped_content_controls.html

    What 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

  • 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

  • @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 file

    There 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

  • 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 at

    https://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

  • 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

Learn what document properties in Microsoft Word can be used for. How to add document properties in Word, how to edit and insert document properties, etc.

When used wisely, document properties and DocProperty fields can help you produce better Word documents in less time.

In this article, you will learn what a document property is and what a DocProperty field is. You will learn where to find the Advanced Properties in Word. The article explains how you can use the built-in functionality of Word to add or edit document properties and insert DocProperty fields, both via the general user interface and via macros (VBA).

The general information below about Microsoft Word document properties and DocProperty fields apply to both custom document properties and DocProperty fields you create using Word’s built-in functionality and using the Word add-in DocTools DocPropertyManager.

It can be slow and tiresome to work with Word’s built-in functionality when it comes to document properties. The DocTools DocPropertyManager Word add-in makes the work much easier and faster. Custom document properties and DocProperty fields created using DocTools DocPropertyManager will work as if they had been created using Word’s built-in functionality. However, DocTools DocPropertyManager makes it possible to perform several tasks that are not possible via the built-in functionality.

This article is relevant for Word 2007, Word 2010, Word 2013, Word 2016, Word 2019, and Word for Microsoft 365. Note that DocTools DocPropertyManager does not work with Word 2007.

What is a document property in Word?

There are different types of document properties.

  • Standard document properties – can also be called built-in document properties
  • Custom document properties
  • Document library properties

All Word documents contain a set of standard document properties, e.g. Title, Author, Keywords, and Comments. These properties are used to store certain types of metadata about your document. The standard properties have fixed names that you cannot change. You can edit the value of some of the standard properties (e.g. Title, Author, Keywords and Comments) whereas others store statistics data that is updated automatically by Word and that cannot be edited, e.g. file size, when the document was last saved or printed.

In addition to the standard properties, you can add Word document properties yourself. Such properties are called custom document properties. Word documents do not contain any custom document properties by default. You can add as many custom document properties as you wish. Each custom document property must be assigned a name, a data type and a value. There are four data types: TextDateNumber and Yes or No. For details about the types, see About the different data types of custom document properties below.

Document library properties are related to documents that are stored in a document library on a website or in a public folder, e.g. in relation to SharePoint. This article will not deal further with document library properties.

Back to Table of Contents 

What can document properties be used for?

None of the Word document properties are visible in the document content unless you do something to insert their values into the content. This is true for both the standard and the custom document properties.

In e.g. File Explorer, you can see and search for documents with specific standard document property values. This article will concentrate on what you can use document properties for in the contents of Word documents.

You can insert the value of a document property in the document. You do so by inserting a field of the type DocProperty. A DocProperty field will show the value of the related document property – standard or custom. See How to insert a DocProperty field using the built-in functionality of Word later in this article.

For an illustration of what document properties and DocProperty fields can be used for, see this short video. The video shows the DocTools DocPropertyManager add-in in use. You can use document properties and DocProperty fields for the same purpose by using Word’s own features. The difference is that the work is more cumbersome and takes longer.

In many documents you may need the same data repeatedly. For example, a client name or a product name may occur several times. It is very helpful to use custom document properties for such data.

You can insert as many DocProperty fields related to the same document property as you wish. If you change the value of that custom document property, you only need to update fields. Then the new value will appear throughout the document. This applies regardless of whether one or many DocProperty fields exist. Thereby, you can define the value once and you are sure that the same value will be shown in every single DocProperty field related to that custom document property.

There are other ways to repeat data. For example, you can bookmark text and have the contents of the bookmark repeated by inserting cross-references to the bookmark. On the DocTools DocPropertyManager page, I have explained why the use of bookmarks and cross-references is less stable than the use of custom document properties and DocProperty fields.

Custom document properties and DocProperty fields also make it easy to create templates with flexible boilerplate text. This way, you can re-use text across documents. For example, this is useful in templates for proposals and agreements. It makes it fast and safe to update the contents with correct names and other values in the individual documents that are created. In the template, simply insert DocProperty fields as placeholders for the relevant data. Assign neutral, descriptive values to the custom document properties in the template. Then it is easy for the user to see which type of information each DocProperty holds. When a user creates a new document based on the template, he/she only needs to edit the values of the custom document properties and update fields.

For an example of the use of custom document properties and DocProperty fields, see the short video on the DocTools DocPropertyManager page.

Fact list

  • A document property has a name and a value. A custom document property also has a type.
  • The value of a document property can be inserted in Word documents using fields of the type DocProperty.
  • You can add as many custom document properties in Word as you want.
  • Custom document properties that have been added to a Word document are preserved in the document regardless of whether they are used in any DocProperty field.
  • The field code of a DocProperty field must refer to the name of the document property whose value you want to appear in the document.
  • You can repeat data in a document by inserting as many DocProperty fields referring to the same document property name as you wish.
  • You can use DocProperty fields in Word templates as placeholders for document-specific data.
  • To change the value of all instances of a specific DocProperty field, edit the value of the related document property and update fields.

Document properties in a template are inherited by new documents based on the template

If you want all documents that are based on a specific template to start with special values of standard properties (e.g. Title and Company) and/or a set of custom document properties, make sure these data are set up in the template. All documents based on the template will initially inherit the document properties and their values. Users of the template can then modify the values of the document properties in the individual document.

Once a Word document has been created, Word has no built-in feature for copying document properties from other documents.

Note that the DocTools DocPropertyManager add-in lets you import custom documents from one document to another. This makes it easy to re-use metadata between documents. The add-in also lets you export custom documents to a document for easy overview in a table. You can even edit properties directly in the table and add custom document properties based in the table data, ready for import into other documents.

Back to Table of Contents

How to edit the values of standard document properties

If you want to edit the value of standard document properties, you need to open the built-in Properties dialog box.

Where is document properties in Word?

In newer versions of Word, the Properties dialog box is well hidden. You must find it under the name Advanced Properties. Follow the instructions below.

How to open the Properties dialog box in Word

How to open the Properties dialog box depends on your version of Word. Note that at least one document must be open in Word in order to open the Properties dialog box.

Word 2010 and later versions

Select File > Info (left side of dialog box) > click the Properties drop-down > select Advanced Properties.

Document properties Word – How to find Advanced Properties in Word

How to find Advanced Properties in Word.

Select Office button > Prepare (left side of dialog box) > in the Document Information Panel that opens below the Ribbon in Word, click the Properties drop-down > select Advanced Properties.

TIP: You can add the Properties dialog box to the Quick Access Toolbar (QAT) for easier access. The name of the command to find in the Word Options dialog box is Advanced Document Properties. For help on how to add a command to the QAT, see How to add a command or macro to the Quick Access Toolbar.

Note that DocTools DocPropertyManager provides easy access to the Properties dialog box in case you need to edit standard document properties.

Document properties Word – The built-in Properties dialog box

Example of the Properties dialog box showing properties for a new, blank document. The name of the document appears in the title bar of the dialog box, in this case «Document3».

As can be seen in the illustration to the left, the Properties dialog box has a number of tabs: General, Summary, Statistics, Contents, and Custom. All tabs except Custom are related to standard properties.

The Summary tab has fields that let you specify a value for each of the following standard properties:

Title
Subject
Author
Manager
Company
Category
Keywords
Comments

To edit the values:

  1. Type the values you want to assign to the individual properties. You may leave any of the fields empty.
  2. Click OK when finished.

How to add or edit custom document properties

How to add document properties in Word

The built-in functionality of Word lets you add custom document properties via the Properties dialog box.

  1. Open the Properties dialog box and select the Custom tab. See How to open the built-in Properties dialog box.
  2. Type a name in the Name field (up to 255 characters).
  3. Select a data type in the Type field (see About the different data types of custom document properties for details).
  4. Type a value in the Value field (up to 255 characters, however, the value must comply with the data type you selected).
  5. Click Add to add the property to the Properties list. If you are creating only one document property, you can skip this step. If you are going to add more document properties, repeat steps 2-5.
  6. Click OK when finished.

Word document properties – The Custom tab of the Properties dialog box

The Custom tab of the Properties dialog box lets you add custom document properties. In this example, two custom document properties have been added.

Word document properties – Example of property with Link to content turned on

Example of property with Link to content turned on.

Below the Name list, you will find a number of suggested names you can select from, if relevant. The result is the same as typing the name directly in the Name field.

Word custom properties link to content

About the Link to content check box
Note the check box Link to content, next to the Value field. Custom document properties with Link to content turned on will show a link icon to the left of the name.

If you turn on Link to content, the label Value changes to Source and the field changes to a drop-down list. The drop-down list shows the names of all bookmarks in the document. Select a bookmark name from the list. If you insert a DocProperty field that refers to the custom document property in question, Word will (or rather: may…) insert the content of the bookmark. If the content of the bookmark is changed, the content of any DocProperty field referring to that bookmark should change too when fields are updated. But that only seems to happen if you, after the bookmark change, open the Properties dialog box and click OK – and then updated fields. 

There are also other important limitations to the bookmark content shown in such DocProperty fields: Only plain text is included in the field result and only up to 255 characters no matter what is included in the bookmark. This means that you cannot use Link to content to have DocProperty fields show longer texts or non- textual content like images or tables.

Since it is doubtful how safe and/or useful it is to use this Link to content option, the DocTools DocPropertyManager add-in does not let you add custom document properties with this option turned on. If a document contains custom document properties added via the built-in Properties dialog box and if Link to content is turned on, DocTools DocPropertyManager will detect this in case you attempt to modify the property. You will then be asked whether you want to modify the property via the built-in dialog box instead.

The built-in Properties dialog box cannot be resized. This makes it impossible to see the full names and/or full values in many cases.

The dialog box for creating and editing custom document properties in the DocTools DocPropertyManager add-in is flexible and has room for longer names and values. In addition, it lets you sort the properties alphabetically. Also, a Filter field makes it fast to find a specific property in the list. When you click a property in the list, you will see information about how many DocProperty fields are found in the document that refer to that property.

How to edit document properties in Word

You could as well ask: How to modify document properties in Word. The terms edit and modify mean the same in this situation. You can edit (modify) the value of a custom document property.

  1. Open the Properties dialog box and select the Custom tab. See How to open the built-in Properties dialog box.
  2. In the Properties list, select the relevant document property.
  3. In the Value field, edit the value.
  4. If you are going to add or edit (modify) more document properties now, click Modify, else click OK.
  5. If one or more DocProperty fields in the document refer to the modified property/properties, update fields (Ctrl+A to select all, F9 to update fields).

How to rename custom document properties in Word

The built-in functionality in Word does not let you change the name of a custom document property. The DocTools DocPropertyManager add-in lets you easily rename custom document properties.

Once you have added a custom document property, you can edit its value but you cannot change the name using Word’s built-in features. The only way to change the name of a custom document property is to delete the old property and add a new one. IMPORTANT: In addition, you will need to change the field code of any DocProperty field that refers to the custom document property in question. Otherwise, such field will show Error! Unknown document property name once fields have been updated.

If you use Word'b built- in feature, you must change the field code in DocProperty fields if you have deleted an old property and created a new to change the name

If you use Word’s built- in feature, you must change the field code in DocProperty fields if you have deleted an old document property and added a new one to change the name.

As opposed to the cumbersome procedure needed for renaming a custom document property using Word’s own features, the DocTools DocPropertyManager add-in lets you rename any existing custom document property simply by changing its name. DocTools DocPropertyManager will automatically do all the work for you, including correcting the field code in any DocProperty field that refers to the renames document property.

How to insert document properties in Word

To insert a document property in Word, you must insert a field of the type DocProperty. Using the built-in functionality, you can insert a DocProperty field either via the Field dialog box or by typing the field code manually. Both methods are described below. Note that the DocTools DocPropertyManager add-in makes it much faster and easier to insert DocProperty fields.

How to insert a DocProperty field using the Field dialog box

  1. In the document, click where you want the DocProperty field to be inserted.
  2. Select the Insert tab.
  3. in the Text group on the Ribbon, click the Quick Parts drop-down and select Field to open the Field dialog box.
  4. In the Categories list, select either (All) or Document Information,
  5. In the Field names list, select DocProperty.
  6. In the Property list, select the name of the document property whose value the DocProperty field is to show. See the illustration of the Field dialog box below.

       The list includes both the standard properties and custom properties, if any.

  7. Click OK to insert the DocProperty field.

The Field dialog box ready for inserting a DocProperty field

The Field dialog box ready for inserting a DocProperty field.

NOTE: By default, Preserve formatting during updates is turned on. If turned on, the MERGEFORMAT switch will be added to the field code. Personally, I always turn the option off since it may result in undesired formatting. For example, a field with the switch may appear with bold text if the field has once shown an error. If special formatting is desired, it is more stable to add relevant switches for the formatting directly.

DocProperty field showing field codes

DocProperty field showing field code and field result.

How to insert a DocProperty field by typing the field code manually

If you know the name of the document property you want to use, it is faster to type the field code manually than using the Field dialog box. The same is true for many other types of fields in Word.

  1. In the document, click where you want the DocProperty field to be inserted.
  2. Press Ctrl+F9 to insert a pair of field brackets (cannot be typed manually).
  3. Between the field brackets, type the following field code:

       DOCPROPERTY «[name of property]»

       where you replace [name of property] with the name of the desired property.

       The use of uppercase and lowercase in the field code is without importance. If the property name consists of one word only, you may leave out the quotation marks. If the property name includes at least one space, you must add the quotes. Therefore, I recommend that you always add quotes for consistency.

  4. Press F9 to update the field and turn off field codes.
    If the field for some reason still shows field codes, press Alt+F9 to show the field result instead. 

How to fix Error! Unknown document property name

If a DocProperty field refers to a property name that does not exist in the document, the field will show an error when fields are updated: Error! Unknown document property name. See the illustration below:

Example of DocProperty field showing an error because it refers to a property that does not exist

Example of DocProperty field showing an error because it refers to a property that does not exist. The error test will be shown in the language of your Word.

The error will occur if you have deleted the custom document property to which the field refers. The error will also occur if you insert content that has been copied from another document and if that content includes DocProperty fields that refer to property names that don’t exist in the target document.

To fix the error, do one of the following:

  1. Add the missing custom document property and update fields. You can find the property name to use by checking the field code of the error field.
    OR
  2. Change the field code in the error field to match an existing custom document property. Then update the field.
    OR
  3. Delete the DocProperty field and edit the surrounding content as needed.

The DocTools DocPropertyManager add-in lets you easily add all missing custom document properties, if any, by the click of a button.

Are DocProperty fields updated automatically?

Note that DocProperty fields do not update automatically. If the value of one or more properties referred to in DocProperty fields has been changed, you need to update the fields to reflect the changes.

You can update DocProperty fields manually by selecting all (Ctrl+A) and pressing F9.

For detailed information about how all types of fields are updated, see my article Updating Fields in Word – How it Works.

Note that the DocTools DocPropertyManager add-in automatically updates DocProperty fields when needed.

About the different data types of custom document properties

As mentioned above, custom document properties can be of the types Text, Date, Number and Yes or No. Below, you will find a description of each type.

Text is the most commonly used type. The other types, Date, Number and Yes or no require specific values and in the document, such fields will not always insert a value that is identical to the value you specify in the Properties dialog box. Therefore, you must make sure that you fully understand how the values of those types work before you start using them.

I use custom document properties and DocProperty fields in the main part of the many Word documents I work with. I always define custom document properties of the type Text.

Type of custom document property

Description – how it works

DocProperty fields that insert a Text property, inserts precisely the text you specify as the value of the property. Most often, you can use the type Text for all DocProperty fields. The value can include max. 255 characters.

The built-in functionality only lets you enter plain text as the value, without any paragraph breaks or manual line breaks. The DocTools DocPropertyManager add-in lets you add the following characters:

  • nonbreaking spaces
  • nonbreaking hyphens
  • en dashes
  • em dashes
  • manual line breaks
  • paragraph breaks

You must enter a value in a date format that matches the definition in the regional settings on your PC.

You may need to experiment since the language settings also influence the way Date properties work.

In case of a standard Danish setting, you can, for example, use the syntax dd-mm-yyyy, e.g. 31-05-2019. A DocProperty field in the document may not always show the date as it appears in the value you specify. You may instead use the type Text. This way, you can enter the date value precisely as you want it to appear in the DocProperty fields in the document.

You must specify a number, either an integer or a decimal number. The decimal symbol to use depends on the regional settings on your PC. If the decimal symbol is a period you can, e.g., enter 12345.678 as a value. A DocProperty field in the document will show the specified value. You may enter a number value with a thousands separator but Word ignores the separator in the field result.

You may enter the following:

*   -1 (corresponds to yes) or 0 (corresponds to no) or
*   True (corresponds to yes) or false (corresponds to no)

When you insert DocProperty fields, the value in the document will only be ‘Y’ for yes and ‘N’ for no.

How to manage document properties and DocProperty fields via macros (VBA)

Below, you will find VBA code examples showing:

  • How you can edit the values of standard document properties via VBA
  • How you can add custom document properties and edit the values of custom document properties via VBA
  • How you can insert DocProperty fields via VBA

These code samples may help you create useful macros. The DocTools DocPropertyManager add-in lets you do much more than that.

In order to create solid VBA code, you will need to add error handling to handle the types of errors that might occur. The code samples below do not include such error handling.

Back to Table of Contents

How to edit the values of standard document properties via VBA

Below are examples of VBA code to edit each of the standard document properties found on the Summary tab of the Properties dialog box.

By using names from the wdBuiltInProperty enumeration, you are sure to use correct names that will work in any language version of Word. Each property also has a number that can be used but your VBA code is much easier to understand if you use the names.

For a full list of the wdBuiltInProperty enumeration for Word, see https://docs.microsoft.com/en-us/office/vba/api/word.wdbuiltinproperty. Note the comments after each of the listed properties – some are not supported in Word even if they are in the list.

Examples of VBA code for editing the values of the standard properties in the active document found on the Summary tab of the Properties dialog box:

ActiveDocument.BuiltInDocumentProperties(wdPropertyTitle) = "My Title"
ActiveDocument.BuiltInDocumentProperties(wdPropertySubject) = "My Subject"
ActiveDocument.BuiltInDocumentProperties(wdPropertyAuthor) = "My Author"
ActiveDocument.BuiltInDocumentProperties(wdPropertyManager) = "My Manager"
ActiveDocument.BuiltInDocumentProperties(wdPropertyCompany) = "My Company"
ActiveDocument.BuiltInDocumentProperties(wdPropertyCategory) = "My Category"
ActiveDocument.BuiltInDocumentProperties(wdPropertyKeywords) = "My Keywords"
ActiveDocument.BuiltInDocumentProperties(wdPropertyComments) = "My Comments"

If you are editing two or more values, you should use With and End With as shown below:

With ActiveDocument
    .BuiltInDocumentProperties(wdPropertyTitle) = "My Title"
    .BuiltInDocumentProperties(wdPropertySubject) = "My Subject"
    .BuiltInDocumentProperties(wdPropertyAuthor) = "My Author"
End With

How to add a custom document property via VBA

The VBA code below adds a custom document property in the active document, with the name «My property», link to content turned off, type «Text» and value «My property value»:

ActiveDocument.CustomDocumentProperties.Add _
    name:="My property", _
    LinkToContent:=False, _
    Value:="My property value", _
    Type:=msoPropertyTypeString

The Type can be one of the following:

  • msoPropertyTypeString
    Corresponds to the type Text in the Properties dialog box > Custom tab.
  • msoPropertyTypeDate
    Corresponds to the type Date in the Properties dialog box > Custom tab.
  • msoPropertyTypeNumber or msoPropertyTypeFloat
    Corresponds to the type Number in the Properties dialog box > Custom tab.
    In case of a decimal number value, the type must be msoPropertyTypeFloat. The decimal symbol must match the decimal symbol defined in regional settings.
    In case of an integer value, the type must be msoPropertyTypeNumber.
  • msoPropertyTypeBoolean
    Corresponds to the type Yes or no in the Properties dialog box > Custom tab.

For more details about the data types, see About the different data types of custom document properties.

How to edit the value of a custom document property via VBA

The VBA code below changes the value of a custom document property named «My property» to «My new property value»:

ActiveDocument.CustomDocumentProperties("My property").Value = "My new property value"

The VBA code also works if you leave out «.Value» since .Value is the default property. However, I recommend always adding the property. It makes the code easy to read and you don’t run into problems.  The example below has left out the default property .Value (not recommended even if it works):

ActiveDocument.CustomDocumentProperties("My property") = "My new property value"

The new value you assign must match the type of custom document property. For example, you can only assign the value in the example above if the type of custom document property is Text. If you assign a value that does not match the type, a run-time error occurs, saying «Type mismatch».

How to insert a DocProperty field via VBA

The VBA code below inserts a DocProperty field at the selection, referring to a custom document property named «My property». If no document property with the specified name exists, the field will show an error.

If you want the MERGEFORMAT switch to be turned on for the field, change PreserveFormatting from False to True.

The double quotation marks around «My property» are needed to have quotation marks added in the field code. There are other ways of adding the quotation marks, e.g. using the character code Chr(34).  You could then replace «»My property»» with this instead:
Chr(34) & «My property» & Chr(34)

Selection.Fields.Add _
    Range:=Selection.Range, _
    Type:=wdFieldEmpty, _
    Text:="DOCPROPERTY  ""My property"" ", _
    PreserveFormatting:=False

The field code of the inserted field will look like this:

{ DOCPROPERTY «My property» }

The field result depends on the value of the property named «My property».

How to handle both built-in and custom document properties in the same VBA code 

If you want to be able to handle both built-in properties and custom document properties using the same macros/VBA code, see How to use a single VBA procedure to read or write both custom and built-in Document Properties.

How to find information about the field switches

In the general help on Word, you can find information about the different types of switches that can be used with specific fields.

The fastest way to find this information is often to search using your preferred browser. You can search for «field codes [TYPE OF FIELD] field» (example: «field codes docproperty field») or something similar.

More tips about working with fields in Word

Turn on field shading so you can distinguish fields from other content

In documents with fields, it is important to be able to distinguish fields from normal text so you don’t accidentally change a field result by manually modifying its result. If you manually modify a field result, the change will disappear the next time the field is updated unless the field has been locked.

Therefore, I recommend that you set the Word option for Field shading to Always (File > Options > Advanced > Show document content group > Field shading > Always). With field shading on, all fields are shown with gray shading on the screen. The gray shading is only visible on the screen in Word – it does not print and it is not visible in PDF.

Information about how different types of fields are updated

For detailed information about how all types of fields are updated, see my article Updating Fields in Word – How it Works.

Useful shortcuts related to fields in Word

For information about keyboard shortcuts related to fields, see my article Word Fields – Useful Keyboard Shortcuts.

Back to Table of Contents

Free Trial icon

Generate complete documents in seconds from re-usable text or graphics

Manage comments in Word fast and easy – review comments, extract comments to Word or Excel, etc.

Simplify and speed up the management of cross-references even in your most complex documents

Manage and repeat data in Word fast and easy with custom document properties and DocProperty fields

Extract insertions, deletions and comments from any Word document, incl. context and headings

Apply any highlight color or remove highlight in Word with a single click – customizable shortcuts

Browse pages, sections, headings, tables, graphics, etc. and find text in Word with a single click

Check safety-critical procedure documents for human factor issues in minutes – improve quality and help prevent errors

Create screen tips in Word fast and easy – with up to 2040 characters

Once you understand how custom document properties and DocProperty fields in Word work, you will be able to create Word documents more efficiently. If you use custom document properties and DocProperty fields for metadata and repeated data, if is easier for you to keep the document data updated and correct.

This article has explained how to add document properties in Word, how to edit document properties in Word, how to insert document properties using DocProperty fields, etc. I hope this article helps you in your future work with custom document properties and DocProperty fields in Word.

Страницы 1

Чтобы отправить ответ, вы должны войти или зарегистрироваться

1 12.01.2012 17:03:02

  • Дмитрий Ш.
  • рядовой
  • Неактивен
  • Зарегистрирован: 12.01.2012
  • Сообщений: 1

Тема: Форма ввода Docproperty

Доброго здравия всем!
Подскажите, есть ли способ вводить свойства Docproperty удобнее, чем через СвойстваДополнительные свойстваПрочие (стандартным способом в MS Word 2010)?
Можно ли форму сорганизовать для этого дела?
Спасибо заранее.

2 Ответ от Вождь 12.01.2012 20:25:22

  • Форма ввода Docproperty
  • Вождь
  • Модератор
  • Неактивен
  • Зарегистрирован: 07.01.2010
  • Сообщений: 745
  • Поблагодарили: 181

Re: Форма ввода Docproperty

Можно использовать старый диалог свойств из Word 2003. Ему соответствует команда FileProperties (не помню, как ее обзывают по-русски). Создайте ее кнопку или привяжите к клавишам.

Можно и через макрос:
Application.Dialogs(750).Show
или
Application.Run «FileProperties»

Макросы под заказ и готовый пакет — mtdmacro.ru

3 Ответ от gurilev 26.01.2012 13:43:00

  • gurilev
  • рядовой
  • Неактивен
  • Зарегистрирован: 24.01.2012
  • Сообщений: 6
  • Поблагодарили: 1

Re: Форма ввода Docproperty

Присоединяюсь к Дмитрию Ш.

Хочу создать как раз такую форму.
Макет формы готов, как пример можно посмотреть на картинке: maket-formy.jpg.
Форма появляется при нажатии созданной в Ворде кнопки.

У меня стояла задача сделать следующее.

В документе, до открытия формы, Свойство «Адрес» уже было прописано — «Санкт-Петербург».

Мне необходимо обновить это поле. Я открываю форму и в поле «Адрес» пишу «Москва». После нажатия «Обновить» форма закрывается, а «Санкт-Петербург» меняется на «Москва», при том, если это поле в нескольких местах в документе, обновляется оно везде.

С написанием команды для кнопки «Обновить» проблем не возникло.
Возникла проблема с написанием команд в Visual Basic (VB) для самих полей: «Адрес», «Количество» и пр.

В интернете удалось найти, как с помощью VBA создать Свойство и прописать в нем значение:

Private Sub cmd_Update_Click()
    ‘Добавление в документ трех пользовательских свойств
    With ActiveDocument.CustomDocumentProperties
            .Add Name:=»Кому», _
            LinkToContent:=False, _
            Type:=msoPropertyTypeString, _
            Value:=»Документ», _
            LinkSource:=»»
    End With
End Sub

Но вот как изменить с помощью VB уже существующее значение поля, пока не смог найти… Подскажите, пожалуйста, или может ссылку кто даст, где почитать.

Через СвойстваДополнительные свойстваПрочие, в том числе и макрос, которые приводит к ним, делать можно, но хочется проще, т.к. делаю не для себя.

Спасибо!

Post’s attachments

maket-formy.jpg 35.29 Кб, 2 скачиваний с 2012-01-26 

You don’t have the permssions to download the attachments of this post.

4 Ответ от aap77 26.01.2012 23:36:25

  • aap77
  • генерал-полковник
  • Неактивен
  • Зарегистрирован: 12.09.2011
  • Сообщений: 925
  • Поблагодарили: 243

Re: Форма ввода Docproperty

Поля надо оформить как закладки LinkToContent:=False «Связать с содержимым» поставить True, тогда эти поля будут автоматически обнвляться……….

5 Ответ от gurilev 31.01.2012 10:22:21

  • gurilev
  • рядовой
  • Неактивен
  • Зарегистрирован: 24.01.2012
  • Сообщений: 6
  • Поблагодарили: 1

Re: Форма ввода Docproperty

Закладки, как я понимаю, прописываются на странице, а свойства документа нет, они как бы «виртуальны».  По этой причине, мне удобней использовать именно свойства.

Кое-как я продвинулся в решении данного вопроса, но то, что сейчас получается, меня не очень устраивает. Форму можно посмотреть в прилагаемом файле UserForma.docm.
В нем, после нажатия на кнопку, появляется форма, которая имеет три поля: Адрес, Заказчик и третье пустое поле (ниже объясню почему оно есть) и кнопка Обновить.

Что в ней не устраивает:
— заполнение поля происходит посредством появления нового мини-окна, а нужно, чтобы данные вводились напрямую в существующие поля; не могу найти команды, которые позволили бы связать Текстовое поле со Свойством документа;
— в полях Адрес и Заказчик по умолчанию должны отображаться значения Свойств каждый раз, когда появляется форма. В том случае, если Свойство, к примеру Адрес, вообще не создано или не заполнено его значение, в поле должно прописываться «не создано» или «пусто», соответственно. Сейчас это работает, но данная информация указывается в Мини-окне при вводе данных, что не очень удобно.
— третье пустое поле — в том случае, если его убрать, то почему-то меняется порядок работы с формой: сначала появляется мини-окно, в котором требуется ввести данные, а уже потом сама форма. При наличии этого пустого поля, форма работает корректно. Полей изначально было больше, чем два, лишние поля удалил и потом заметил, что меняется порядок;
— Свойства документа (Адрес и Заказчик) прописываются автоматически после клика на соответствующее поле, даже если в мини-окне нажать «Cancel». Это не очень удобно, может быть оно и не нужно, а получается, что появляется даже если ты случайно нажал на это поле.

Как можно решить данные вопросы?

В довесок: что-то подобное, но более навороченное, я нашел на сайте «Maoyr & Maxey» по следующей ссылке:
внешняя ссылка
У них разработана единая форма для редактирования и Закладок и Свойств документа и еще чего-то. Вещь удобная, но: она на английском, она идет как Надстройка и не каждый в ней сможет разобраться…

Post’s attachments

UserForma.docm 33.59 Кб, 19 скачиваний с 2012-01-31 

You don’t have the permssions to download the attachments of this post.

Страницы 1

Чтобы отправить ответ, вы должны войти или зарегистрироваться

00_lead_image_insert_custom_property

Недавно мы показали, как устанавливать расширенные или встроенные свойства и создавать пользовательские свойства в документе Word. Эти свойства могут быть вставлены в ваши документы, используя поля. Это полезно, если у вас есть общие слова, фразы или значения, которые вы часто используете в своих документах.

СВЯЗАННЫЕ: Как установить дополнительные свойства документа Word

Если общее слово, фразы и значения, которые вы часто используете, будут меняться между первым и последним черновиками документа, полезно использовать встроенное или настраиваемое свойство. Вы можете изменить значение свойства в одном месте, и оно будет меняться во всем документе.

Чтобы вставить значение встроенного или пользовательского свойства в ваш документ, поместите курсор туда, куда вы хотите вставить значение, и нажмите вкладку «Вставить».

ПРИМЕЧАНИЕ. При вставке пользовательского свойства в документ вставляется только значение. Если вы хотите сослаться на значение с именем свойства, введите нужный текст, прежде чем вставлять значение свойства.

01_clicking_insert_tab

В разделе «Текст» вкладки «Вставка» нажмите кнопку «Быстрые детали».

ПРИМЕЧАНИЕ. Текст на кнопках может не отображаться в зависимости от размера окна Word. Если вы не видите текст рядом с кнопкой, найдите значок, указанный на рисунке ниже.

02_clicking_quick_parts

Выберите «Поле» в раскрывающемся меню.

03_selecting_field

Выберите «Информация о документе» в раскрывающемся списке «Категории».

04_selecting_document_information

В списке «Имена полей» выберите «DocProperty». Список всех пользовательских свойств (как встроенных, так и добавленных вами) отображается в списке «Свойства» в разделе «Свойства поля» в середине диалогового окна. Выберите пользовательское свойство, которое вы хотите вставить в ваш документ, из списка и нажмите «ОК».

05_selecting_docproperty

Значение вставляется там, где находится курсор.

06_custom_property_inserted

Если вы измените значение пользовательского свойства, вы можете обновить поля в документе, чтобы отразить это изменение, выбрав все поля, что легко сделать, выбрав все содержимое в документе и нажав клавишу F9. Вы также можете обновить по одному полю за раз, выбрав поле или поместив курсор в поле и нажав F9.

Like this post? Please share to your friends:
  • Do while vba excel примеры
  • Do we have spell check in excel
  • Do until for vba excel
  • Do this word search square and see if you can find 10 words connected with
  • Do this exercise while you listen complete the gaps with the correct word that