Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: print record of minimized Word documents?  (Read 7477 times)

0 Members and 1 Guest are viewing this topic.

melissagish10

  • Guest
Re: print record of minimized Word documents?
« Reply #15 on: November 09, 2010, 04:32:11 PM »
The MRU is stored in the registry. Unfortunately it is stored as a  sequence of null-terminated strings which I could not figure out how to represent in a batch file. This little snippet of VBScript code may help:

Code: [Select]
' List the documents in the Word MRU registry key
'
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"

Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
  strComputer & "\root\default:StdRegProv")
 
oReg.GetMultiStringValue HKEY_CURRENT_USER, strKeyPath, strValueName, arrValues

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

Save the script with a VBS extension. It can be run from the command prompt as cscript scriptname.vbs or wscript scriptname.vbs If run with the former, output will be directed to the console as a list of documents. If run with the latter, outout will be a single window with all the documents listed. To produce a hardcopy, use cscript and redirect the output to your printer Ex: cscript scriptname.vbs > lpt1 .

Note: I'm still using Word XP (2002) so I got the Word 2003 registry key from the internet. With any luck it is correct. In any case, the registry is used only for reading, so there is no danger of mucking it up.

Good luck.  8)


Uhmm this looks complex for me. Is there any simpler explanation? Thanks.

Sidewinder



    Guru

    Thanked: 139
  • Experience: Familiar
  • OS: Windows 10
Re: print record of minimized Word documents?
« Reply #16 on: November 10, 2010, 03:45:30 PM »
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.

Quote
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.

Quote
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.

Quote
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.

Quote
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.  8)
The true sign of intelligence is not knowledge but imagination.

-- Albert Einstein