Damaged word files?

B

Bronsdijk

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
 
D

DA

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
 
B

Bronsdijk

Thanks Dennis. The automation part of the code works great. But the
new files still have the long opening time problem. Maybe word doesn't
rewrite the whole file but just add some new lines because the file
size increases if you compare the old and the new file.

kevin
 
D

DA

Hi Kevin

Unfortunately the slow opening could be related to a host
of troubling issues. If things get totally unworkable,
try saving each doc as a webpage and then reopen it in
word and save again as a doc.

In the past I've also had some small measure of luck if I
do a copy and paste into a blank doc. This is only
advisable if you're using good style and page layout
practices and can set up identical styles in your target
doc.

Dennis
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top