Re: DOC to TXT



You can use FileSystemObject to browse files and folders in your specified folder, and use it to delete the document.

Dim doc As Word.Document
Dim fso, folder, subFolder, docFile
Dim sPath As String

Set fso = CreateObject("Scripting.FileSystemObject")
Set folder = fso.GetFolder("E:\Training\docs")

For Each subFolder In folder.SubFolders
For Each docFile In subFolder.Files
If UCase(Right(docFile.Name, 4)) = ".DOC" Then
sPath = docFile.Path
Set doc = Documents.Open(sPath, , , False, , , , , , , , False)
sPath = docFile.Path & ".txt"
doc.SaveAs sPath, Word.wdFormatText
doc.Close False
docFile.Delete
End If
Next
Next

"Mike Berger" <mike_berger@xxxxxxxx> ???? news:#qDapNmBJHA.1628@xxxxxxxxxxxxxxxxxxxxxxx
Hello Newsgroup!

I have a foldertree with 3 underfolders, that include about 500 .doc
documents.

I will open the .doc automatily and then saving as .txt and if possible
delete the .doc file from the disc.

I can open one file with VBA, when I have the filename in the code.

It's possible to make that with VBA?

Thank you.
Mike

.



Relevant Pages

  • RE: Word/Character Count for a Group of Documents
    ... and character count in a table ... Dim sPath As String ... Dim sActivePath As String ... ' Make sure that the active document is not in the folder ...
    (microsoft.public.word.vba.general)
  • Re: HTML Item properties vs. Regular item properties
    ... I don't use the MSN provider, but AFAIK the date in the default store's is ... OutlookSpy - Outlook, CDO ... as well as the Sent Items folder on the MSN server. ... Dim app As Outlook.Application ...
    (microsoft.public.outlook.program_vba)
  • RE: If Statement help
    ... Dim newbk As Variant ... Right now the macro takes all the files in the current folder, ... 'This is very useful in quickly archiving and storing daily batch files ... Dim objFile As File, strSourceFolder As String, strDestFolder As String ...
    (microsoft.public.excel.programming)
  • RE: If Statement help
    ... Dim newbk As Variant ... Right now the macro takes all the files in the current folder, ... 'This is very useful in quickly archiving and storing daily batch files ... Dim objFile As File, strSourceFolder As String, strDestFolder As String ...
    (microsoft.public.excel.programming)
  • RE: If Statement help
    ... "Denise Pollock" wrote: ... Dim newbk As Variant ... Right now the macro takes all the files in the current folder, ... Dim objFile As File, strSourceFolder As String, strDestFolder As String ...
    (microsoft.public.excel.programming)