Is it possible to make a list from a directory straight to Office
Word, and adding layout?
When i do this in DOS: dir c:\ /s/a/o >c:\content.doc
It doesn't have a layout.
Is it possible to give the result a layout (like the dirs are H1)
Normal text = H3
And so on
Open your "content.doc" document and format the heading 1 and heading 2
style as you wish. Reduce the space before and after and uncheck the "Keep
with next" checkbox on the second tab page of the Paragraph fromat dialog.
Then run the code below. On my machine (A Pentium 4 machine at work), it
took 28 seconds to go through a 2,476-page document (Which is the document
that I got after running your code: dir c:\ /s/a/o >c:\content.doc).
Sub Format_Dir()
Dim paraDoc As Paragraph
'To avoid repaginating and accelerate things a bit.
Application.ScreenUpdating = False
With ActiveDocument
With .Range(.Paragraphs(1).Range.Start, .Paragraphs(2).Range.End)
.Font.Size = 16
.Font.Bold = True
.ParagraphFormat.Alignment = wdAlignParagraphCenter
End With
End With
For Each paraDoc In ActiveDocument.Paragraphs
If InStr(1, paraDoc.Range.Text, "Directory of") > 0 Then
paraDoc.Style = wdStyleHeading1
ElseIf InStr(1, paraDoc.Range.Text, "<DIR>") > 0 Then
paraDoc.Style = wdStyleHeading2
End If
'Otherwise you get an undo list with over 20,000 entries...
ActiveDocument.UndoClear
Next
Application.ScreenRefresh
Application.ScreenUpdating = True
End Sub