[mso] Re: print a list

  • From: "Greg Chapman" <greg@xxxxxxxxxxxxx>
  • To: <mso@xxxxxxxxxxxxx>
  • Date: Sun, 8 Dec 2002 14:24:18 -0600

Here's a way to use Word to generate your list using Word since the only
other way Windows will do it for you is from a Windows Script Host file.
All you have to do make this work is:

1. Open MS Word
2. From the File Menu, choose New
3. Select the Normal Blank Template and set the document type to
Template
4. Once the new Template is open, click File, then Save As and save it
as a Template (.DOT file) called "ListAllPrograms.dot"
5. Press Alt + F11. This opens the VB Editor
6. From the Insert Menu in the VB Editor, choose Module
7. Copy the following (everything between the lines of equal signs
(e.g.,"============")) and paste it into the new code module and proceed
to step 8

'============================================================
Public objFSO
Public arrDirs


Sub PrintAllPrograms()

Set objFSO = CreateObject("Scripting.FileSystemObject")

GetSpecialFolders

ActiveDocument.Sections(1).PageSetup.Orientation = _
    wdOrientLandscape

With Selection
    .Font.Underline = wdUnderlineSingle
    .Font.Size = 10
    .Font.Bold = True
    .TypeText Text:="Programs for Current User: " & _
    arrDirs(0) & vbCrLf
    .Font.Bold = False
    .Font.Size = 8
    .Font.Underline = wdUnderlineNone
End With

EnumFolders (arrDirs(0)), 0
Selection.TypeText Text:=Chr(124) & vbCrlLf
EnumFiles (arrDirs(0)), 0

Selection.InlineShapes.AddHorizontalLineStandard

With Selection
    .TypeText Text:=vbCrLf
    .Font.Underline = wdUnderlineSingle
    .Font.Bold = True
    .Font.Size = 10
    .TypeText Text:="Programs for All Users: " & _
    arrDirs(1) & vbCrLf
    .Font.Bold = False
    .Font.Size = 8
    .Font.Underline = wdUnderlineNone
End With

EnumFolders (arrDirs(1)), 0
Selection.TypeText Text:=Chr(124) & vbCrlLf
EnumFiles (arrDirs(1)), 0

End Sub

'-----------------------------------------------------------

Private Sub GetSpecialFolders()

Dim wshShell

ReDim arrDirs(1)

Set wshShell = CreateObject("WScript.Shell")
  
arrDirs(0) = wshShell.SpecialFolders("AllUsersPrograms")
arrDirs(1) = wshShell.SpecialFolders("Programs")

Set wshShell = Nothing

End Sub

'-----------------------------------------------------------

Private Sub EnumFolders(strFolderPath, intDepth As Integer)

Dim Folders, SubFolders, i

If intDepth <> 0 Then
    For i = 0 To intDepth
        strTab = strTab & vbTab
    Next i
Else
    strTab = ""
End If

Set Folders = objFSO.GetFolder(strFolderPath)
Set SubFolders = Folders.SubFolders

For Each Folder In SubFolders
    With Selection
        .Font.Underline = wdUnderlineSingle
        .Font.Bold = True
        .TypeText Text:=Chr(124) & strTab & " - " & _
            Folder.Name & vbCrLf
        .Font.Bold = False
        .Font.Underline = wdUnderlineNone
    End With
    EnumFolders Folder.Path, intDepth + 1
    EnumFiles Folder.Path, intDepth + 1
Next Folder

strTab = ""

End Sub

'-----------------------------------------------------------

Private Sub EnumFiles(strFolderPath, intDepth As Integer)

Dim Files, Folder, i

If intDepth <> 0 Then
    For i = 0 To intDepth
        strTab = strTab & vbTab
    Next i
Else
    strTab = ""
End If

Set Folder = objFSO.GetFolder(strFolderPath)
Set Files = Folder.Files

For Each File In Files
    If strTab <> "" Then
        Selection.TypeText Text:=Chr(124) & strTab & Chr(124) & _
            " - " & File.Name & vbCrLf
    Else
        Selection.TypeText Text:=Chr(124) & strTab & " - " & _
        File.Name & vbCrLf
    End If
Next File

strTab = ""

End Sub
'============================================================

8. Still in the VB Editor, click File, then Save
9. Close the VB Editor
10. From within Word again, choose File, then New, then select the
ListAllPrograms Template
11. If you don't get a warning about macros, you'll need to visit the
Tools, Macros, Security menu and set the option to Medium. Close the new
document without saving and repeat step 10. Answer "Enable macros" in
the warning dialog. Don't worry, there are no viruses in the above code
and all macro laden Word docs will now bring you up a warning and
request about enabling or disabling macros from now on.
12. Once macros are enabled, click the Tools menu again, then Macros and
select "PrintAllPrograms" from the list.

Now the macro will run and create a new document that lists all the
program groups and the program links in each group. You can either save
the document for later reference or you can go ahead and print it out
right now.

Hopefully, that will do as you need. If you have any problems, please,
feel free to write me directly for a copy of the template sent direct
via email. Personally, I love to see people use their office apps to
manage their operating systems!

Greg Chapman
http://www.mousetrax.com 
"Counting in binary is as easy as 01, 10, 11!
With thinking this clear, is coding really a good idea?"


> -----Original Message-----
> From: mso-bounce@xxxxxxxxxxxxx 
> [mailto:mso-bounce@xxxxxxxxxxxxx] On Behalf Of Bob Garsson
> Sent: Sunday, December 08, 2002 12:08 AM
> To: mso
> Subject: [mso] print a list
> 
> 
> 
> Using WinXP, is there any way to print a list of what comes 
> up when you click on start|all programs? TIA Bob 
> 
> 
> --- Bob Garsson
> --- bgarsson4@xxxxxxxxxxxxx
> --- EarthLink: The #1 provider of the Real Internet.
> 
>

*************************************************************
You are receiving this mail because you subscribed to mso@xxxxxxxxxxxxx or 
MicrosoftOffice@xxxxxxxxxxxxxxxx

To send mail to the group, simply address it to mso@xxxxxxxxxxxxx

To Unsubscribe from this group, send an email to 
mso-request@xxxxxxxxxxxxx?Subject=unsubscribe

Or, visit the group's homepage and use the dropdown menu.  This will also allow 
you to change your email settings to digest or vacation (no mail).
//www.freelists.org/webpage/mso

To be able to use the files section for sharing files with the group, send a 
request to mso-moderators@xxxxxxxxxxxxx and you will be sent an invitation with 
instructions.  Once you are a member of the files group, you can go here to 
upload/download files:
http://www.smartgroups.com/vault/msofiles
*************************************************************

Other related posts: