Word macro - remove shading from active para. and assign language to it, keep text cursor position
Hello,
I am trying to create a macro that would do what the subject says, i.e. remove shading from the paragraph in which the text cursor is located, and assign language to that paragraph, while keeping the position of the text cursor.
I tried to do this by recording my actions in a macro - I select the whole paragraph, start a new macro (name it, assign a keyboard shortcut) - click the shading icon in the toolbar and pick No Color, then invoke the language menu and select and confirm the desired language - and stop recording.
The macro then looks like this:
Sub EngUSNoBackground()
'
' Macro1 Macro
'
'
Selection.Shading.Texture = wdTextureNone
Selection.Shading.ForegroundPatternColor = wdColorAutomatic
Selection.Shading.BackgroundPatternColor = wdColorAutomatic
Selection.LanguageID = wdEnglishUS
Selection.NoProofing = False
End Sub
What this does when I run it while nothing is selected, is only remove shading from the whole document, and does not assign the language. When I run it again, then it changes the language of only the word where the cursor is.
I could work around this by recording two steps before anything else (Ctrl+Up, Ctrl+Shift+Down) to select the paragraph, and that does the trick, but I want to keep the position of the text cursor in the paragraph.
Can anyone help me with this, what do I need to put into the macro for it to be applied to the active paragraph, without having to select the text of the paragraph first?
|