How can I programmatically open 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 added a button to the ribbon that will save the document in the database. But before the document is saved, I want the user to look into the document properties window so that they can fill in the document properties (for example, "Title", "Subject" and "Author"). I use the following statement to open a window:

Application.Dialogs(750).Display 

This works fine, but by default it shows the General tab. The fields for the title, topic and author) are on the Summary tab. Is there a way to bring up this dialog box and redirect it to the Summary tab? I was thinking 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 does not have a window with multiple tabs.

+4
source share
3 answers

You can create a separate block for this (works in Word 2000, 2003, 2007 and 2010):

 Application.Dialogs(wdDialogFileSummaryInfo).Display 

or

 Application.Dialogs(86).Display 

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

+3
source

You can record a macro and execute it as needed.

+1
source

Changing .Display to.Show works, except that you get an error message if you press ESC, so you need to wrap it in On Error Resume Next (I don’t know why).

 Sub CustomProperties() On Error Resume Next Application.Dialogs(750).Show End Sub 
0
source

Source: https://habr.com/ru/post/1316302/


All Articles