View Single Post
 
Old 05-14-2023, 05:07 AM
suuki suuki is offline Windows 11 Office 2016
Novice
 
Join Date: May 2023
Posts: 1
suuki is on a distinguished road
Default Problem with quick parts

Hi there. I am trying to use this feature to replace a text with another.
I have already selected the text and went to quicks parts/autotext/save selection to autotext gallery


However when I run the macro, I got the error 5941, telling that the element doesn't exist. I checked the name used to save the selected text and it is correct, so I dont know what is the problem.


The macro is the following:


Sub Document_Open()
SubstitutePage
End Sub
Sub AutoOpen()
SubstitutePage
End Sub
Sub SubstitutePage()
ActiveDocument.Content.Select
Selection.Delete
ActiveDocument.AttachedTemplate.AutoTextEntries("a ne").Insert Where:=Selection.Range, RichText:=True
End Sub
Reply With Quote