Disabling PowerPoint Recent Files list

S

Stumpiana

I'm automating PowerPoint (Office 2000) from another VB application and can't
seem to disable the Recent Files list. I have tried calling
<CommandBarButton>.Enabled = false and also <CommandBarButton>.Delete and in
both cases the error message I get is:
Method 'Enabled' of object '_CommandBarButton' failed
Method 'Delete' of object '_CommandBarButton' failed

Has anyone been able to successfully do this in any version of PowerPoint?

Thanks, Marianne
 
B

Bill Dilworth

Would it be acceptable just to fill the recently used file list with
fictious entries?
**Fill the MRU (Most Recently Used) list with bogus file names
http://www.rdpslides.com/pptfaq/FAQ00373.htm

Can we assume that you do not want the name/path of the automated
presentation to be available from the file pulldown list?

--
Bill Dilworth
Microsoft PPT MVP Team
Users helping fellow users.
===============
Please spend a few minutes checking vestprog2@
out www.pptfaq.com This link will yahoo.
answer most of our questions, before com
you think to ask them.

Change org to com to defuse anti-spam,
ant-virus, anti-nuisance misdirection.
..
..
 
S

Stumpiana

I'm automating PowerPoint from an application in which we control the File
open, save, saveas, close and only allow 1 file (or workbook) to be open at a
time. If the user is allowed to select anything in the Recent files list,
another workbook gets opened in the application and I'm trying to prevent
this. Here is some code I'm using to disable the Open, Save, etc., along
with the code that doesn't work for the recent files:

Private Sub CustomPptObject(objPpt As PowerPoint.Application, _
Optional BlnSaveEnabled As Boolean = True, _
Optional intResultCode As Integer = gconstOK)

'Customize the powerpoint object to be display inside the DocContainer.
On Error GoTo CustomPptObjectErr

'Dim objRecentFile As Word.RecentFile

'disable certain File menu options
With objPpt.CommandBars("Menu Bar")
.Controls("&File").Controls("&New...").Enabled = False
.Controls("&File").Controls("&Open...").Enabled = False
.Controls("&File").Controls("&Close").Enabled = False
.Controls("&File").Controls("&Exit").Enabled = False
.Controls("&File").Controls("Save &As...").Enabled = False
.Controls("&File").Controls("Save").Enabled = BlnSaveEnabled
' PowerPoint 2000 or greater
If mstrOfficeVersion = OFFICE_2000 Then
.Controls("&File").Controls("Save as Web Pa&ge...").Enabled = False
End If
End With

'disable the standard toolbar.
'"New &Blank Document"
With objPpt.CommandBars("Standard")
.Controls(1).Enabled = False
'&Open...
.Controls(2).Enabled = False
'&Save
.Controls(3).Enabled = BlnSaveEnabled
End With

'remove the recentFile list
'Search for menu items starting with "&1...", "&2...", etc.
Dim I As Integer
Dim J As Integer
Dim StartIdx As Integer
Dim EndIdx As Integer
Dim Pos As Integer
Dim CmdBarButton As Office.CommandBarButton
StartIdx = 0
EndIdx = 0
With objPpt.CommandBars("Menu Bar").Controls("&File")
For I = 1 To .Controls.Count
OutputDebugString .Controls(I).Caption
Pos = InStr(.Controls(I).Caption, "&1")
If Pos = 1 Then
'match found for first recent file
StartIdx = I
End If
Pos = InStr(.Controls(I).Caption, "&Recent")
If Pos = 1 Then
EndIdx = I
Exit For
End If
Next
On Error Resume Next
If StartIdx > 0 And EndIdx >= StartIdx Then
'Disable these menu items
For J = StartIdx To EndIdx
'TBD: None of these work!
Set CmdBarButton = .Controls(J)
CmdBarButton.Visible = False
If Err.Number <> 0 Then OutputDebugString Err.Description & vbCrLf
CmdBarButton.Enabled = False
If Err.Number <> 0 Then OutputDebugString Err.Description & vbCrLf
CmdBarButton.Delete
If Err.Number <> 0 Then OutputDebugString Err.Description & vbCrLf
Next
End If
End With

Exit Sub

CustomPptObjectErr:

On Error Resume Next
OutputDebugString "Error in CustomPptObject: " & Err.Description & vbCrLf

End Sub
 
S

Stumpiana

Now that I can automate PowerPoint in Office 2003, with your help getting the
window handle, I see that the Recent Files list is not disabled. It looks
like with Office 2003 (and maybe 2002?) the MRUListActive registry entry is
not there. Is there a different way to disable the RecentFiles list in
PowerPoint 2003 (and 2002)?
 
S

Stumpiana

Please disregard this question. All I needed to do was create a
MRUListActive registry key myself and the recent files list was still
disabled. Sorry.
 

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