A family of Microsoft word processing software products for creating web, email, and print documents.
The paragraph shading can be best handled using a paragraph style, not a macro.
Are you trying to set up Table Styles?
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Word has several command settings that I would like to change the default for. I just can't figure out the syntax.
.
I want the Paragraph Shading color to default to yellow and the Table Borders command to default to All Borders.
.
I want these commands set when I open a file.
I recorded a macro to create the commands, but they depend on something being selected. Is there any syntax I can use without selecting?
The original command for shading included "Selection.", that didn't work so tried dropping it, still didnt' work.
Or do I have to go through process of inserting a dummy object (a 1cell table) turning on the settings, then deleting the dummy table?
.
Sub AutoExec()
'
' AutoExec Macro
'
'
Shading.Texture = wdTextureNone
Shading.ForegroundPatternColor = wdColorAutomatic
Shading.BackgroundPatternColor = wdColorYellow
With Selection.Borders(wdBorderTop)
.LineStyle = wdLineStyleSingle
.LineWidth = Options.DefaultBorderLineWidth
.Color = Options.DefaultBorderColor
End With
With Selection.Borders(wdBorderLeft)
.LineStyle = wdLineStyleSingle
.LineWidth = Options.DefaultBorderLineWidth
.Color = Options.DefaultBorderColor
End With
With Selection.Borders(wdBorderBottom)
.LineStyle = wdLineStyleSingle
.LineWidth = Options.DefaultBorderLineWidth
.Color = Options.DefaultBorderColor
End With
With Selection.Borders(wdBorderRight)
.LineStyle = wdLineStyleSingle
.LineWidth = Options.DefaultBorderLineWidth
.Color = Options.DefaultBorderColor
End With
With Selection.Borders(wdBorderVertical)
.LineStyle = wdLineStyleSingle
.LineWidth = Options.DefaultBorderLineWidth
.Color = Options.DefaultBorderColor
End With
With Selection.Borders(wdBorderHorizontal)
.LineStyle = wdLineStyleSingle
.LineWidth = Options.DefaultBorderLineWidth
.Color = Options.DefaultBorderColor
End With
End Sub
A family of Microsoft word processing software products for creating web, email, and print documents.
Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.
The paragraph shading can be best handled using a paragraph style, not a macro.
Are you trying to set up Table Styles?
If you create the following macro in the template from which you create the documents,
Sub AutoNew()
With Selection
.Shading.ForegroundPatternColor = wdColorAutomatic
.Shading.BackgroundPatternColor = wdColorYellow
End With
End Sub
when you create a new document, you wlll get:
Is that really what you want to happen?
By default, tables are created with all borders applied.
No, I'm trying to avoid that highlighted paragraph. I just want the shading color to be set to yellow when I need it, because that is the color I use. As it stands, every time I open a new document and want to highlight something I first have to select the color. I'm lazy.
So it appears I have to use the Selection mode.
What is the command to delete current selection.
Looks like I can't do what I want.
.
I copy a lot of content from the web that is formatted as tables. They mostly come in as no borders. Again, I have to select the all borders option before it can be applied the first time. It stays selected after that until the document is closed.
If you create the following macro in the template from which you create the documents,
Sub AutoNew()
With Selection
.Shading.ForegroundPatternColor = wdColorAutomatic
.Shading.BackgroundPatternColor = wdColorYellow
End With
End Sub
when you create a new document, you wlll get:
Is that really what you want to happen?
By default, tables are created with all borders applied.