Damaged word files? by DA
DA
Mon Jul 05 17:38:29 CDT 2004
Hi Kevin
I suggest you expand on this to give you some error
checking, but this simple example should get you
started.
The routine will get all word documents from an input
directory and save them as a copy with a "_new.doc"
extension.
----------------
Sub DocCopySave()
Dim strInputDir As String
Dim lngFileCount As Long
Dim lngCounter As Long
strInputDir = InputBox("Enter Input Directory")
With Application.FileSearch
.NewSearch
.LookIn = strInputDir
.FileType = msoFileTypeWordDocuments
.SearchSubFolders = False
.Execute
lngFileCount = .FoundFiles.Count
On Error Resume Next
For lngCounter = 1 To lngFileCount
Documents.Open FileName:=.FoundFiles(lngCounter)
ActiveDocument.SaveAs FileName:= _
.FoundFiles(lngCounter) + "_new.doc"
ActiveDocument.Close
Next lngCounter
End With
End Sub
--------
Hope that helps,
Dennis
>-----Original Message-----
>After a power outage and a corporate upgrade to word 2003
>(we don't now which is responsible for al the problems)
we have
>problems with opening word files.
>It sometimes takes up to 5 minutes to open a simple word
file. When it
>finally opens we save the content to a different word
file (by hand).
>Now the question is can this task be automated? We don't
just want to
>loop true al the files in VBA and do a save document. It
must be some
>kind of a copy al content and save that as a new
document function but
>how can we do this? What is the best way to select al of
the content?
>
>Thanks in advance.
>Kevin Bronsdijk
>
>.
>