Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I programmatically bring up the document properties window in Word and go to the Summary tab?

I am developing a VB6 COM add-in for Microsoft Word and I have added a button to the Ribbon which will save the document to a database. But before the document is saved, I want to take the user to the document properties window so they can fill in the properties for the document (like Title, Subject and Author). I am using the following statement to bring up the window:

Application.Dialogs(750).Display

This works fine, but it defaults to showing them the General tab. The fields for Title, Subject and Author) are on the Summary tab. Is there any way to bring up this dialog box and force it over to the Summary tab? I thought about sending keystrokes, but the tabs don't have hotkeys associated with them.

I need this to work in Word 2007 and Word 2010. The line above already works fine in Word 2003 because 2003 doesn't have a multi-tabbed properties window.

like image 210
CowherPower Avatar asked Jul 20 '10 15:07

CowherPower


3 Answers

You can bring up a seperate box for this (works in both Word 2000, 2003, 2007 and 2010):

Application.Dialogs(wdDialogFileSummaryInfo).Display

or

Application.Dialogs(86).Display

You can also program against this dialog. See here for an example.

like image 133
Todd Main Avatar answered Oct 22 '22 11:10

Todd Main


You could record a macro then execute it as needed.

like image 33
Ash Burlaczenko Avatar answered Oct 22 '22 11:10

Ash Burlaczenko


Changing .Display to .Show works, except you get an error if you press ESC, so you have to wrap it in On Error Resume Next (no idea why).

Sub CustomProperties()
    On Error Resume Next
        Application.Dialogs(750).Show
End Sub
like image 1
Wade Hatler Avatar answered Oct 22 '22 12:10

Wade Hatler