Wow! This is your lucky day. Today, and today only, explanations are just 5¢ and simpler explanations are just 7¢. As usual the script is free.
Const HKEY_CURRENT_USER = &H80000001
strComputer = "."
strKeyPath = "Software\Microsoft\Office\11.0\Common\Open Find\Microsoft Word\Settings\Save As\File Name MRU"
strValueName = "Value"
Assigns the registry key to various variables. The registry key is specific to Word 2003 and will be different for other versions. Also designates the local computer to do the processing.
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
strComputer & "\root\default:StdRegProv")
oReg.GetMultiStringValue HKEY_CURRENT_USER, strKeyPath, strValueName, arrValues
This is the heart of the script. Connects to the WMI class which contains the properties and methods needed to access the Windows registry. The MRU is a sequence of null-terminated strings, which the
GetMultiStringValue returns as an array. Arrays are easy to process in VBScript, a registry sequence of null-terminated strings not so much.
If arrValues(0) = "" Then
WScript.Echo "MRU List Is Empty"
WScript.Quit
End If
If the MRU is empty, this error trap will allow for a gentle landing instead of the script crashing into the side of a mountain. Well maybe not so dramatic, but if you have an empty MRU you'll see the results from this code.
If Right(LCase(WScript.FullName), 11) = "cscript.exe" Then
For Each strValue In arrValues
WScript.Echo "Document - " & strValue
Next
Else
For Each strValue In arrValues
strBlock = strBlock & "Document - " & strValue & vbCrLf
Next
WScript.Echo strBlock
End If
This code formats the output returned in the array of MRU items. It queries which interpreter is being used (VBScript has two) and takes advantage of how the
echo instruction works in each.
And there you have it. Please pay the cashier on your way out.
Good luck.