Avatar of grayderek
grayderekFlag for United Kingdom of Great Britain and Northern Ireland

asked on 

Code to Open Properties for user input

I have a macro the updates parts of the document based on the standard properties
I need a macro the opens the properties box for user input and preferably runs my other macro on close.  I do not want buttons etc or customise the toolbar with properties button as it is not always retained.
Microsoft Word

Avatar of undefined
Last Comment
grayderek
Avatar of irudyk
irudyk
Flag of Canada image

Try adding this to the end of your existing macro
Application.Dialogs(wdDialogFileSummaryInfo).Show
Avatar of irudyk
irudyk
Flag of Canada image

Sorry, I meant to add the code to the start of your existing macro.  Or you could create a new macro such as:
 

Sub NewMacro()
    Application.Dialogs(wdDialogFileSummaryInfo).Show
    Call YourExistingMacro
End Sub

Open in new window

Avatar of grayderek
grayderek
Flag of United Kingdom of Great Britain and Northern Ireland image

ASKER

Thanks it is very close, the trouble is this does not show the 'Manager' and 'Company' within the summary info of properties, both of which I want the user to. Any Help
Avatar of irudyk
irudyk
Flag of Canada image

Okay, try using:

Sub NewMacro()
    'bypass error if user clicks the Cancel button
    On Error Resume Next
    'show file properties dialog
    WordBasic.FileProperties
    'reset error hadling
    On Error GoTo 0
    Call YourExistingMacro
End Sub

Open in new window

Avatar of Eric Fletcher
Eric Fletcher
Flag of Canada image

The wdDialogFileSummary dialog is just a subset of what you see in the File | Properties menu item's dialog, and despite what you might expect, wdDialogFileProperties won't work. However the following will:

Application.Dialogs(750).Show

I have no idea why this would be so cryptic when most of the other dialogs use names based on the menu.

You can include this in your code to put up the same dialog as you'll get with the File | Properties menu. The built-in variables wdPropertyCompany and wdPropertyManager contain the values for the properties you want.
Avatar of grayderek
grayderek
Flag of United Kingdom of Great Britain and Northern Ireland image

ASKER

So close, both solutions work prefer 'irudyk' because of error trapping, however when ok or cancel is pressed it reverts to any window other than the document being worked on.  Any further code?
ASKER CERTIFIED SOLUTION
Avatar of irudyk
irudyk
Flag of Canada image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of grayderek
grayderek
Flag of United Kingdom of Great Britain and Northern Ireland image

ASKER

Thanks for your perseverance
Microsoft Word
Microsoft Word

Microsoft Word is a commercial document editing program that is part of the Microsoft Office suite. It features numerous text-editing tools for creating richly formatted documents, along with tools for the use of macros in Word documents. Word's native file formats are denoted either by a .doc or .docx file extension. Plugins permitting the Windows versions of Word to read and write formats it does not natively support, such as the OpenDocument format (ODF) are available. Word can import and display images in common bitmap formats such as JPG and GIF. It can also be used to create and display simple line-art.

30K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo