Written by Allen Wyatt (last updated December 16, 2022)
This tip applies to Word 2007, 2010, and 2013
Bill wonders how he can get the Properties dialog box for a document to display from within a macro. In Word 2003 he can do this manually by choosing Properties from the File menu, but the process is a bit more complex in Word 2007 with the need to display the Document Information Panel and then displaying the advanced properties.
Even though the way that you display the Properties dialog box is different in Word 2007 than it is in earlier versions of the program, the way you do it in a macro is not different. You can display a Word dialog box in VBA by using this syntax:
Dialogs(name).Show
This works because VBA makes accessible dialog boxes through the Dialogs collection. The trick is to determine what you should use in the place of name in the syntax. For instance, if you wanted to display the Open dialog box, you could use the following:
Dialogs(wdDialogFileOpen).Show
You can find a complete list of dialog box constants at this site:
http://msdn.microsoft.com/en-us/library/bb214033.aspx
Unfortunately, there is no "wdDialogFileProperties" constant that you can use with the Dialogs collection. This means that the full Properties dialog box cannot be displayed. You can, however, display "pieces" of the dialog box. For instance, you could use the following to display the information found on the Summary tab of the Properties dialog box:
Dialogs(wdDialogFileSummaryInfo).Show
This will work in any version of Word, including Word 2007. If you want to display the Document Information Panel, which is new to Word 2007, then you do so not by using the Dialogs collection, but by using the following code:
Application.DisplayDocumentInformationPanel = True
Note:
WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (7482) applies to Microsoft Word 2007, 2010, and 2013.
Create Custom Apps with VBA! Discover how to extend the capabilities of Office 2013 (Word, Excel, PowerPoint, Outlook, and Access) with VBA programming, using it for writing macros, automating Office applications, and creating custom applications. Check out Mastering VBA for Office 2013 today!
You may need to determine the numeric value of a character in a macro. You can do that using the Asc function, described ...
Discover MoreWriting macros often involves selecting different parts of your document so that some sort of processing can be ...
Discover MoreWhen processing text with a macro, you often need to remove extraneous spaces from the text. VBA provides three handy ...
Discover MoreFREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."
2023-04-11 05:21:49
Lene Fredborg
It is possible to open the Properties dialog box via VBA even if Microsoft has not provided a constant for the dialog box. See my article "How to show the Properties dialog box via VBA": https://www.thedoctools.com/word-macros-tips/word-macros/show-properties-dialog-via-vba/.
2019-03-28 14:08:35
Neman Syed
Thanks for your tip Allen. It's a pity something so important - metadata location - is buried enough to make it daunting for a user. I'm currently designing a template and looking for an easy way to have the users maintain custom document properties. I didn't want to use a macro, but may have to, as it's been difficult to find the corresponding toolbar button.
The Document Information Panel has been removed as of Office 2016 as per https://support.office.com/en-gb/article/where-is-the-document-information-panel-in-office-2016-767bbbbb-27aa-42e8-81dc-9ed5cf06e6e0. Your readers may need to take action accordingly.
Got a version of Word that uses the ribbon interface (Word 2007 or later)? This site is for you! If you use an earlier version of Word, visit our WordTips site focusing on the menu interface.
Visit the WordTips channel on YouTube
FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2024 Sharon Parq Associates, Inc.
Comments