Thank you for being a valued part of the CNET community. As of December 1, 2020, the forums are in read-only format. In early 2021, CNET Forums will no longer be available. We are grateful for the participation and advice you have provided to one another over the years.

Thanks,

CNET Support

General discussion

Word Macro: Save file as text with current file name

Sep 4, 2010 6:30PM PDT

(My knowledge of VB is close to non-existent - I just want to record and run a macro)

Using MS-Word 2007.

I have about 100 files, named "1.doc", "2.doc", etc.
I need to edit them, and then convert them all to text files, using "File | Save As."

Using "1.doc" as my example, I record a macro, and go through the entire "File | Save As" process - merely changing the file type to text, and then the formatting, and saving it as "1.txt"

It works fine with this file, but, when I run the macro on "2.doc", it wants to save it ALSO as "1.txt", because the macro actually records the file name (not the key strokes). (See the macro below).

So, I need it to get the current file name, and save file as currentfilename.txt.

Macro:
~~~~~~
----

Sub FileSaveAsClose()
'
' FileSaveAsClose Macro
'
'
ActiveDocument.SaveAs FileName:="1.txt", FileFormat:=wdFormatText, _
LockComments:=False, Password:="", AddToRecentFiles:=True, WritePassword _
:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, _
SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:= _
False, Encoding:=65001, InsertLineBreaks:=False, AllowSubstitutions:= _
False, LineEnding:=wdCRLF
End Sub

-----


Thanks in advance.

Discussion is locked

- Collapse -
That has been discussed earlier.
Sep 4, 2010 6:43PM PDT
- Collapse -
Yup, but I couldn't get it
Sep 4, 2010 6:56PM PDT

Yeah, thanks, I had seen that earlier post, and have spent about 30 minutes already getting nowhere. By doing it manually, it takes time, but will work. By teaching myself, it will probably take longer, and there's the risk that it still won't work, and I'll still have to do it manually anyway.

I guess I'll just have to do it manually.

Thanks anyway.