Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.docmanagement
Jack Burman Jack Burman is offline
external usenet poster
 
Posts: 4
Default Word macro to save files as .txt

Would like to strip formatting from large group of small files and save as
text files.
Can a Word 2003 macro be created that will take a folder of small .docs and
save all .docs as .txt files. If so, how can this be done? If not, is there
some other method that can be used to automate this task.

Ultimately, would like to concatenate all .txt files into one large file and
use in another program - not word processing program.

Thanks
  #2   Report Post  
Posted to microsoft.public.word.docmanagement
Doug Robbins - Word MVP Doug Robbins - Word MVP is offline
external usenet poster
 
Posts: 8,832
Default Word macro to save files as .txt

You could modify the macro in the article "Find & ReplaceAll on a batch of
documents in the same folder€¯ at:

http://www.word.mvps.org/FAQs/MacrosVBA/BatchFR.htm

by deleting all of the stuff about finding and replacing so that it just
opened each document and incorporating the following example from the Visual
Basic Help file so that it saved each document as a text file

Sub SaveAsTextFile()
Dim strDocName As String
Dim intPos As Integer

'Find position of extension in file name
strDocName = ActiveDocument.Name
intPos = InStrRev(strDocName, ".")

If intPos = 0 Then

'If the document has not yet been saved
'Ask the user to provide a file name
strDocName = InputBox("Please enter the name " & _
"of your document.")
Else

'Strip off extension and add ".txt" extension
strDocName = Left(strDocName, intPos - 1)
strDocName = strDocName & ".txt"
End If

'Save file with new extension
ActiveDocument.SaveAs FileName:=strDocName, _
FileFormat:=wdFormatText
End Sub

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com

"Jack Burman" wrote in message
...
Would like to strip formatting from large group of small files and save as
text files.
Can a Word 2003 macro be created that will take a folder of small .docs
and
save all .docs as .txt files. If so, how can this be done? If not, is
there
some other method that can be used to automate this task.

Ultimately, would like to concatenate all .txt files into one large file
and
use in another program - not word processing program.

Thanks


  #3   Report Post  
Posted to microsoft.public.word.docmanagement
Doug Robbins - Word MVP Doug Robbins - Word MVP is offline
external usenet poster
 
Posts: 8,832
Default Word macro to save files as .txt


You could modify the macro in the article "Find & ReplaceAll on a batch of
documents in the same folder€¯ at:

http://www.word.mvps.org/FAQs/MacrosVBA/BatchFR.htm

by deleting all of the stuff about finding and replacing so that it just
opened each document and incorporating the following example from the Visual
Basic Help file so that it saved each document as a text file

Sub SaveAsTextFile()
Dim strDocName As String
Dim intPos As Integer

'Find position of extension in file name
strDocName = ActiveDocument.Name
intPos = InStrRev(strDocName, ".")

If intPos = 0 Then

'If the document has not yet been saved
'Ask the user to provide a file name
strDocName = InputBox("Please enter the name " & _
"of your document.")
Else

'Strip off extension and add ".txt" extension
strDocName = Left(strDocName, intPos - 1)
strDocName = strDocName & ".txt"
End If

'Save file with new extension
ActiveDocument.SaveAs FileName:=strDocName, _
FileFormat:=wdFormatText
End Sub

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com

"Jack Burman" wrote in message
...
Would like to strip formatting from large group of small files and save as
text files.
Can a Word 2003 macro be created that will take a folder of small .docs
and
save all .docs as .txt files. If so, how can this be done? If not, is
there
some other method that can be used to automate this task.

Ultimately, would like to concatenate all .txt files into one large file
and
use in another program - not word processing program.

Thanks


  #4   Report Post  
Posted to microsoft.public.word.docmanagement
Jack Burman Jack Burman is offline
external usenet poster
 
Posts: 4
Default Word macro to save files as .txt

Thanks. This should do the trick!

"Doug Robbins - Word MVP" wrote:

You could modify the macro in the article "Find & ReplaceAll on a batch of
documents in the same folder€¯ at:

http://www.word.mvps.org/FAQs/MacrosVBA/BatchFR.htm

by deleting all of the stuff about finding and replacing so that it just
opened each document and incorporating the following example from the Visual
Basic Help file so that it saved each document as a text file

Sub SaveAsTextFile()
Dim strDocName As String
Dim intPos As Integer

'Find position of extension in file name
strDocName = ActiveDocument.Name
intPos = InStrRev(strDocName, ".")

If intPos = 0 Then

'If the document has not yet been saved
'Ask the user to provide a file name
strDocName = InputBox("Please enter the name " & _
"of your document.")
Else

'Strip off extension and add ".txt" extension
strDocName = Left(strDocName, intPos - 1)
strDocName = strDocName & ".txt"
End If

'Save file with new extension
ActiveDocument.SaveAs FileName:=strDocName, _
FileFormat:=wdFormatText
End Sub

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com

"Jack Burman" wrote in message
...
Would like to strip formatting from large group of small files and save as
text files.
Can a Word 2003 macro be created that will take a folder of small .docs
and
save all .docs as .txt files. If so, how can this be done? If not, is
there
some other method that can be used to automate this task.

Ultimately, would like to concatenate all .txt files into one large file
and
use in another program - not word processing program.

Thanks


  #5   Report Post  
Posted to microsoft.public.word.docmanagement
Jack Burman Jack Burman is offline
external usenet poster
 
Posts: 4
Default Word macro to save files as .txt

Thanks. This should do the trick!

"Doug Robbins - Word MVP" wrote:

You could modify the macro in the article "Find & ReplaceAll on a batch of
documents in the same folder€¯ at:

http://www.word.mvps.org/FAQs/MacrosVBA/BatchFR.htm

by deleting all of the stuff about finding and replacing so that it just
opened each document and incorporating the following example from the Visual
Basic Help file so that it saved each document as a text file

Sub SaveAsTextFile()
Dim strDocName As String
Dim intPos As Integer

'Find position of extension in file name
strDocName = ActiveDocument.Name
intPos = InStrRev(strDocName, ".")

If intPos = 0 Then

'If the document has not yet been saved
'Ask the user to provide a file name
strDocName = InputBox("Please enter the name " & _
"of your document.")
Else

'Strip off extension and add ".txt" extension
strDocName = Left(strDocName, intPos - 1)
strDocName = strDocName & ".txt"
End If

'Save file with new extension
ActiveDocument.SaveAs FileName:=strDocName, _
FileFormat:=wdFormatText
End Sub

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com

"Jack Burman" wrote in message
...
Would like to strip formatting from large group of small files and save as
text files.
Can a Word 2003 macro be created that will take a folder of small .docs
and
save all .docs as .txt files. If so, how can this be done? If not, is
there
some other method that can be used to automate this task.

Ultimately, would like to concatenate all .txt files into one large file
and
use in another program - not word processing program.

Thanks


Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to count lines and save in differents files Jr Microsoft Word Help 4 May 10th 07 10:56 AM
A Macro to Save Files JeanneJo Microsoft Word Help 8 April 4th 07 06:46 AM
I can't save word or excel files using save as russ45 Microsoft Word Help 1 April 21st 06 03:45 AM
Macro-ing mulitiple word files. [email protected] Microsoft Word Help 1 February 9th 06 12:42 AM
Macro to Merge Word Files John Microsoft Word Help 0 September 27th 05 07:06 PM


All times are GMT +1. The time now is 12:22 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"