Forum Discussion
Selecting a shape and changing its attributes
- Nov 05, 2023
Here is an example:
.
Sub ShapeSelectedFormat() ' ' Charles Kenyon 4 November 2023 ' ' See https://learn.microsoft.com/en-us/office/vba/api/word.shape ' With Selection.ShapeRange(1) .Fill.ForeColor.ObjectThemeColor = wdThemeColorAccent2 .AutoShapeType = msoShapeOval End With End Sub
Here is the support page on the Shape Object.
https://learn.microsoft.com/en-us/office/vba/api/word.shape
You can choose the attributes you want to change within the With structure. They are listed in the support article.
You could attach your macro to a keyboard shortcut and/or a QAT button. Those should be stored in the same template that holds your macro.
- Assigning Keyboard Shortcuts in Microsoft Word 2007-2021 (365)
- Modifying the Quick Access Toolbar (QAT) in Microsoft Word
Word has two Shape collections, Shapes and InLineShapes. I am not sure this will work with both but you are welcome to try it.
Here is an example:
.
Sub ShapeSelectedFormat()
'
' Charles Kenyon 4 November 2023
'
' See https://learn.microsoft.com/en-us/office/vba/api/word.shape
'
With Selection.ShapeRange(1)
.Fill.ForeColor.ObjectThemeColor = wdThemeColorAccent2
.AutoShapeType = msoShapeOval
End With
End Sub
Here is the support page on the Shape Object.
https://learn.microsoft.com/en-us/office/vba/api/word.shape
You can choose the attributes you want to change within the With structure. They are listed in the support article.
You could attach your macro to a keyboard shortcut and/or a QAT button. Those should be stored in the same template that holds your macro.
- Assigning Keyboard Shortcuts in Microsoft Word 2007-2021 (365)
- Modifying the Quick Access Toolbar (QAT) in Microsoft Word
Word has two Shape collections, Shapes and InLineShapes. I am not sure this will work with both but you are welcome to try it.
- cindixNov 05, 2023Copper ContributorThat will do. 🙂
Thank you.