View Single Post
  #1  
Old October 1st, 2004, 12:02 PM
helpserv
external usenet poster
 
Posts: n/a
Default Including Subfolders for use within Word 2003 Macro

Can someone suggest what should be modified to the macro code below,
which will permit including "sub folders" when running the following
macro within Word 2003? Thanks. By the way, the use of this macro is
for a non profit non-discriminatory youth program and your assistance
will make a difference. Thank you for your consideration.

The macro does work perfectly to add to the footer the filename and
path, print date, and page x of y and then prints the document. What
we spent the last 2 weeks trying to do is for the macro to run on
subfolders since we have many documents and many folders. We note
when running the macro as is that we have had to manually go into
every folder individually and then run the macro. Permitting
subfolders to run in addition will save a considerable amount of time
and ensure we have left no folder/ or sub folder out of our print
task. Thank you.


' onlyprint Macro
' Macro created 09/14/2004 by youth org
'

Public Sub onlyprint()
Dim myFile As String
Dim PathToUse As String
Dim myDoc As Document

With Dialogs(wdDialogCopyFile)
If .Display 0 Then
PathToUse = .Directory
Else
MsgBox "Cancelled by User"
Exit Sub
End If
End With


'Close any documents that may be open
If Documents.Count 0 Then
Documents.Close Savechanges:=wdPromptToSaveChanges
End If

If Left(PathToUse, 1) = Chr(34) Then
PathToUse = Mid(PathToUse, 2, Len(PathToUse) - 2)
End If

myFile = Dir$(PathToUse & "*.doc")

While myFile ""
Set myDoc = Documents.Open(PathToUse & myFile)
If ActiveWindow.View.SplitSpecial wdPaneNone Then
ActiveWindow.Panes(2).Close
End If
If ActiveWindow.ActivePane.View.Type = wdNormalView Or
ActiveWindow. _
ActivePane.View.Type = wdOutlineView Then
ActiveWindow.ActivePane.View.Type = wdPrintView
End If
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
If Selection.HeaderFooter.IsHeader = True Then
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageFooter
Else
ActiveWindow.ActivePane.View.SeekView =
wdSeekCurrentPageHeader
End If
Selection.Font.Size = 7
NormalTemplate.AutoTextEntries("Filename and path").Insert Whe=
_
Selection.Range, RichText:=True
Selection.TypeText Text:=" "
NormalTemplate.AutoTextEntries("Print Date").Insert
Whe=Selection.Range _
, RichText:=True
Selection.TypeText Text:=" "
NormalTemplate.AutoTextEntries("Page X of Y").Insert
Whe=Selection. _
Range, RichText:=True

'print and close the document
myDoc.PrintOut
myDoc.Close Savechanges:=wdDoNotSaveChangesClose
myFile = Dir$()

Wend
End Sub