RecentList

A

Adolf Gerold

Hallo VBA-friends

I've wrote a Makro, which deletes the filelist
of the file-menu:

Sub ClearFileList()

Application.DisplayRecentFiles = False

Application.DisplayRecentFiles = True

RecentFiles.Maximum = 9

End Sub

It works correctly, but only if a worddocument is
opened. Otherwise i got an error message.

Can anybody tell my how to solve this problem.
I think, I ask after an open document and if there
is none, I let the macro open one, clear the filelist
and let the makro close the document.

But what's the code?

Thank you for your effort
with kind regards, Adi
 
D

Doug Robbins

Hi Adolf,

Easiest thing to do is open a new document anyway and then close it after
your code runs

Dim mydoc as Document
Set mydoc = Documents.Add
<your code>
mydoc.Close wdDoNotSaveChanges

will do it.
--
Please respond to the Newsgroup for the benefit of others who may be
interested. Questions sent directly to me will only be answered on a paid
consulting basis.

Hope this helps,
Doug Robbins - Word MVP
 
A

Adolf Gerold

Hi Doug
Easiest thing to do is open a new document anyway and then close it after
your code runs

Dim mydoc as Document
Set mydoc = Documents.Add
<your code>
mydoc.Close wdDoNotSaveChanges

will do it.

Thank you, it works great!
With kind regards from Austria
-- Adi --
 

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