vbams-wordrecent-file-list

VBA macro create temporary file


I am using a macro which creates temporary docx files that are then assembled into one. I then delete the temporary files. These files still show up in the Recent Files list, even though they no longer exist. How can I prevent these temp files from being recognized by Word as a recent file?

Or is there a way to save the contents of the would-be temporary file in an array and then use this array to complete the final file? Meaning, the temp file does not ever actually exist.


Solution

  • The fifth parameter of Document.SaveAs is AddToRecentFiles. Set that to False.

    https://msdn.microsoft.com/en-us/library/office/aa220734

    You can create the temporary files, combine them into one, and then close them without saving them.