Copy Selected Text to Document Tags with a Word VBA Macro
Question details
Create a Word macro that copies selected text and opens document properties so the text can be pasted into the Tags field.

- Product
- Microsoft Word
- Device & OS
- not provided
- Scenario
- The user wants to use a selected word as document metadata without typing it again.
- Observed behavior
- The selected text is copied to the clipboard, and the user can paste it into the document's Tags or Keywords property.
Select the word or text you want to use as a tag. Check that your Word installation allows trusted macros to run and supports the built-in document properties dialog.
Copy the selection and open document properties with VBA
Use this macro to copy the selected text and display Word's built-in document properties dialog.
The macro copies the selection but does not paste it automatically. Depending on your Word version, the Tags property may appear as Keywords on the Summary tab.
In Word, open the Developer tab and select Visual Basic. On Windows, you can also press Alt+F11.
In the VBA editor, select Insert > Module and paste this code: Sub CopySelectionToProperties() If Selection.Type = wdSelectionIP Then MsgBox "Select the text you want to use as a tag first." Exit Sub End If Selection.Copy Dialogs(wdDialogFileSummaryInfo).Show End Sub
Return to the document, select the desired text, and choose Developer > Macros. Select CopySelectionToProperties and click Run.
In the properties dialog, open the Summary tab if necessary, paste the copied text into Keywords, and click OK. Save the document to retain the metadata.

Copy text to document properties without a macro
Use Word's menus if macros are unavailable or you only need to add a tag occasionally.
Edit Word Documents with WPS Writer
WPS Office is a free, lightweight alternative with a familiar interface and Microsoft Office format compatibility, making it easy to move existing documents into WPS Writer. It does not fix or run this Microsoft Word VBA solution.

Frequently Asked Questions
Where is the Tags field in Word?
Open File > Info and look for Tags in the document properties. In Advanced Properties, the corresponding field may be labeled Keywords on the Summary tab.
Does the macro paste the tag automatically?
No. It uses Selection.Copy to copy the selected text and opens the properties dialog. You must paste the text into the Tags or Keywords field and confirm the dialog.
What should I do if the properties dialog does not open?
Check whether macros are enabled for the document and whether your Word version supports the dialog command. You can also open File > Info > Properties > Advanced Properties manually.
How can I keep the macro for future use?
Save the macro in a trusted macro-enabled document or template, such as a DOCM or DOTM file. Use File > Save As and choose the appropriate macro-enabled file type.




