E
Ebbe
Hey
I have written a procedure, that searches all *.doc's in a specific path,
prints them out and then deletes them.
The following sub is working perfectly when I run it in the debugger.
But "in real life" it prints out the first found document and then hangs up.
I suppose it is because the "Kill" is executed too quickly after the
"Close"?? I discovered some times that document is deleted, but the
related ~-workfile is still "alive".
Can I insert a sort of time delay between the Close and Kill?
Or is there an other way to solve the problem?
Ebbe
'-------------------------- begin
Sub AutoOpen()
Dim Pattern As String
Dim Path As String
Dim DocName As String
Path = ActiveDocument.BuiltInDocumentProperties("Keywords").Value
Pattern = Path & "\" & "*.doc"
DocName = Dir(Pattern)
Do While DocName <> ""
DocName = Path & "\" & DocName
Documents.Open FileName:=DocName, ReadOnly:=True
Application.PrintOut _
FileName:="", _
Range:=wdPrintAllDocument, _
Item:=wdPrintDocumentContent, _
Copies:=1, _
Pages:="", _
PageType:=wdPrintAllPages, _
ManualDuplexPrint:=False, _
Collate:=True, _
Background:=False, _
PrintToFile:=False, _
PrintZoomColumn:=0, _
PrintZoomRow:=0, _
PrintZoomPaperWidth:=0, _
PrintZoomPaperHeight:=0
ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges
Kill DocName
DocName = Dir(Pattern)
Loop
Application.Quit
End Sub
'-------------------------- end
I have written a procedure, that searches all *.doc's in a specific path,
prints them out and then deletes them.
The following sub is working perfectly when I run it in the debugger.
But "in real life" it prints out the first found document and then hangs up.
I suppose it is because the "Kill" is executed too quickly after the
"Close"?? I discovered some times that document is deleted, but the
related ~-workfile is still "alive".
Can I insert a sort of time delay between the Close and Kill?
Or is there an other way to solve the problem?
Ebbe
'-------------------------- begin
Sub AutoOpen()
Dim Pattern As String
Dim Path As String
Dim DocName As String
Path = ActiveDocument.BuiltInDocumentProperties("Keywords").Value
Pattern = Path & "\" & "*.doc"
DocName = Dir(Pattern)
Do While DocName <> ""
DocName = Path & "\" & DocName
Documents.Open FileName:=DocName, ReadOnly:=True
Application.PrintOut _
FileName:="", _
Range:=wdPrintAllDocument, _
Item:=wdPrintDocumentContent, _
Copies:=1, _
Pages:="", _
PageType:=wdPrintAllPages, _
ManualDuplexPrint:=False, _
Collate:=True, _
Background:=False, _
PrintToFile:=False, _
PrintZoomColumn:=0, _
PrintZoomRow:=0, _
PrintZoomPaperWidth:=0, _
PrintZoomPaperHeight:=0
ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges
Kill DocName
DocName = Dir(Pattern)
Loop
Application.Quit
End Sub
'-------------------------- end