Forum Discussion

Jacobo1680's avatar
Jacobo1680
Copper Contributor
Jan 29, 2024

My macros for Word 2019 don't work with Word 365

Hi everybody and thanks in advance.

 

I have a macro that works fine in Word 2019. When I hit ENTER, a word is wrote in red color (word is <p>).

This is the code:

 

Sub InsertP()
' Enter to macro
CustomizationContext = NormalTemplate
KeyBindings.Add KeyCode:=BuildKeyCode(wdKeyReturn), KeyCategory:=wdKeyCategoryCommand, _
Command:="InsertP"

' Inser </p> to hit Enter
Selection.Font.Color = RGB(255,  0,  0)
Selection.TypeText Text:="</p>"
Selection.Font.Color = RGB(0,  0,  0)
Selection.TypeParagraph
Selection.Font.Color = RGB(255,  0,  0)
Selection.TypeText Text:="<p>"
Selection.Font.Color = RGB(0,  0,  0)
End Sub


If I execute it in Word 365, Normal.dotm becomes corrupt and I have to restore it with a backup copy. Sometimes, it works, but macro always stay activated. I spent 2 days looking for a pattern but I cannot understand where is the problem.

Any help would be good for me.

Thanks 

 

No RepliesBe the first to reply

Resources