Run time error 5941

L

Leila

Hi There,
In some of our PCs for the below code on line:
Set rngLocation =
tplAttached.AutoTextEntries(strAutoTextName).Insert(rngLocation, True)
I get this error:
"Runtime error 5941: the request number of collection does not exist"
Would you please let me know what I'm missing here? is there any
reference(lib) for this error that I might left out?
Thanks so much for your help
---------
Private Sub InsertAutoText(ByVal strAutoTextName As String, _
ByVal strBookmarkName As String)
'This code inserts the AutoText containing the TOC field at the location of
the
'old TOC.

Dim tplAttached As Word.Template
Dim rngLocation As Word.Range

' Insert specified autotext at the bookmarked location
' and then recreate the bookmark
Set tplAttached = ActiveDocument.AttachedTemplate
Set rngLocation = ActiveDocument.Bookmarks(strBookmarkName).Range
Set rngLocation =
tplAttached.AutoTextEntries(strAutoTextName).Insert(rngLocation, True)
ActiveDocument.Bookmarks.Add strBookmarkName, rngLocation
End Sub
 
J

Joost Verdaasdonk

Hi Leila,

The error suggests that the autotext entry does not
exists. (in autotext collection)
So you're probarbly calling an autotext name that doesn't
exists..

Try to insert THAT autotext fragment manualy? (use same
name as the macro does)

Hope this helps,
Groetjes,
Joost Verdaasdonk
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top