AddToRecentFiles Problem

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am writing a macro for a customer and am tryingto use th
AddToRecentFiles:=False parameter to my Doucmnet open statement, and stil
the document shows up in the recent used list. The code is ..

Word.Application.Documents.Open strFilename, , , Fals

I have also trie

Set TheDoc = Word.Application.Documents.Open(Filename:=strFilename
AddToRecentFiles:=False

Niether method seems to work. The rest of the code makes some changes in th
docuemnt and then executes a close comman

' Open the Template as a templat
Set TheDoc
Word.Application.Documents.Open(Filename:=strFilename
AddToRecentFiles:=False

' Set our variable
SetOptions TheDo

' Save the file in its original file format of templat
TheDoc.Close SaveChanges:=wdSaveChanges
OriginalFormat:=wdOriginalDocumentForma

Thanks for your hel
 
Hi Bart

Try this code:

Public Sub DoNotAddToRecentFileList()
Dim TheDoc As Word.Document
Dim strFilename As String

strFilename = "F:\Test\Test - File2.doc"

' Open the Template as a template
Set TheDoc = Word.Application.Documents.Open _
(FileName:=strFilename, AddToRecentFiles:=False)

' Set our variables
SetOptions TheDoc

' Save the file in its original file format of template
TheDoc.SaveAs strFilename, AddToRecentFiles:=False
TheDoc.Close SaveChanges:=wdDoNotSaveChanges
End Sub

There are two points at which Word can add a file to the most recently used
list; when you open it and when you save it. So this one inhibits both actions.

HTH + Cheers - Peter
 

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

Back
Top