Where is my error into this macro?

A

avkokin

Hello.
There is the macro which creates new menu bar in Active menu bar and
full it of list of recent files. But I get error "Run time error
5152". What is my error? Why? And why my menu bar has only 7 item?
Help me, please.
Thank you very much.
 
A

avkokin

Sorry, that my macro:
Sub listMRUF()
Dim rf As Word.RecentFile
CustomizationContext = ActiveDocument
Set cb = CommandBars.ActiveMenuBar
Set oPopup = CommandBars.FindControl(Tag:="rf")
If Not oPopup Is Nothing Then
oPopup.Delete
End If
Set oPopup = cb.Controls.Add(msoControlPopup)
With oPopup
.Caption = "MRUF"
.Tag = "rf"
.BeginGroup = True
End With

For i = 1 To Application.RecentFiles.Count

Set oBtn = oPopup.Controls.Add(msoControlButton)
With oBtn
.Caption = Application.RecentFiles(i).Name
.Style = msoButtonCaption
End With
Next i
Set oPopup = Nothing
Set oBtn = Nothing
End Sub
 

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