Option Explicit
Const wdDoNotSaveChanges = 0
Const wdPromptToSaveChanges = -2
Const wdSaveChanges = -1
' переменные пишем
Dim Hirinka as long
Dim Hirinka_STR as string
Dim Hirina as long
Dim Hirina_STR as string
Dim my_Patch as string
Dim objWord, objDoc, objFS, objFolder, objItem
Dim F as long
Function Cikl()
for F=1 to 20' смотря сколько папок
Hirina_STR = Format(Yaer(F), "0000")
my_Patch = "D:\OTDEL\" & Hirina_STR & "\" & Folder_NAME(дата из поля на форме)
call Printing
next F
end Function
Function Printing ()
Set objFS = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFS.GetFolder("d:\OTDEL\0001\02012009") 'Папка, из которой производится печать
Set objWord = WScript.CreateObject("Word.Application")
For Each objItem In objFolder.Files
If StrComp(objFS.GetExtensionName(objItem.Name), "0001", vbTextCompare) = 0 Then
With objWord
Set objDoc = .Documents.Open(objItem.Path, False, True, False)
objDoc.PrintOut False
Set objDoc = Nothing
End With
End If
Next
objWord.Quit
Set objWord = Nothing
WScript.Quit 0
End Function
Function Folder_NAME(My_Date) As String
Folder_NAME = Format(Day(My_Date), "00") & Format(Month(My_Date), "00") & Format(Yaer(My_Date), "0000")
End Function
|