Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open all files in a directory and save them as docs

Status
Not open for further replies.

guitardave78

Programmer
Sep 5, 2001
1,294
GB
Said it in the title really, i need to be able to choose a directory, open all the files and then save them as doc files with the same name as the original files

Any ideas!?
 
How 'bout this:

Dim pos,ctr as Integer
Dim myDocname as String

With Application.FileSearch
.FileName="*.*"
.LookIn = YourPath
.SearchSubFolders = True or False as you like it
.Execute
For ctr = 1 to .FoundFiles.Count
Documents.Open FoundFiles.Item(ctr)
ChangeFileOpenDirectory YourPath
myDocname=ActiveDocument.FullName
pos = InStr(myDocname, ".")
If pos > 0 Then
myDocname = Left(MyDocname, pos-1)
myDocname=myDocname & ".doc"
ActiveDocument.SaveAs FileName:=myDocname, FileFormat:=wdFormatDocument
End If
ActiveDocument.Close
Next
End With

Should do fine. [pipe]

MakeItSo

Andreas Galambos
EDP / Technical Support Specialist
Bowne Global Solutions Wuppertal, Germany
(andreas.galambos@bowneglobal.de)
HP:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top