|
|
|
date: Thu, 17 Mar 2005 08:55:43 GMT,
group: microsoft.public.word.word6-7macros
back
Save As Plain Text Macro - HELP!
Hi there, can anyone help me with a macro that would automatically Save As
Plain Text a file - keeping its name before the dot and just changing the
extension to .txt? What I have created naturally saves each file to the same
name (NewName.txt below):
Sub Save_As_TXT()
ActiveDocument.SaveAs FileName:="NewName.txt", FileFormat:= _
wdFormatText, LockComments:=False, Password:="",
AddToRecentFiles:=True, _
WritePassword:="", ReadOnlyRecommended:=False,
EmbedTrueTypeFonts:=False, _
SaveNativePictureFormat:=False, SaveFormsData:=False,
SaveAsAOCELetter:= _
False, Encoding:=1252, InsertLineBreaks:=False,
AllowSubstitutions:=False _
, LineEnding:=wdCRLF
End Sub
THANKS for any help!
Gabriele
date: Thu, 17 Mar 2005 08:55:43 GMT
author: Gabriele Azzaro
RE: Save As Plain Text Macro - HELP!
Hi,
Not sure if you find this helpful but
ActiveDocument.SaveAs FileName:="NewName.txt", FileFormat:= _
wdFormatText, LockComments:=False, Password:="",
In this line, store the active document name in a variable and then use that
variable instead of "NewName.txt"
flname=activedocument.name
ActiveDocument.SaveAs FileName:=flname & ".txt", FileFormat:= _
wdFormatText, LockComments:=False, Password:="",
I suppose by now you would have figured it out though, any way hoep you
foudn it useful.
Anand
date: Sun, 15 May 2005 22:24:02 -0700
author: Anand.V.V.N
RE: Save As Plain Text Macro - HELP!
2 Solutions: The long way
Sub SaveAsTextFile()
Dim strDocName As String
Dim intPos As Integer
'Find position of extension in filename
strDocName = ActiveDocument.Name
intPos = InStrRev(strDocName, ".")
If intPos = 0 Then
'If the document has not yet been saved
'Ask the user to provide a filename
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
or the short way:
ActiveDocument.SaveAs FileName:=ActiveDocument & ".txt "
ActiveDocument.Close
--
Jon
"Gabriele Azzaro" wrote:
> Hi there, can anyone help me with a macro that would automatically Save As
> Plain Text a file - keeping its name before the dot and just changing the
> extension to .txt? What I have created naturally saves each file to the same
> name (NewName.txt below):
>
> Sub Save_As_TXT()
>
> ActiveDocument.SaveAs FileName:="NewName.txt", FileFormat:= _
> wdFormatText, LockComments:=False, Password:="",
> AddToRecentFiles:=True, _
> WritePassword:="", ReadOnlyRecommended:=False,
> EmbedTrueTypeFonts:=False, _
> SaveNativePictureFormat:=False, SaveFormsData:=False,
> SaveAsAOCELetter:= _
> False, Encoding:=1252, InsertLineBreaks:=False,
> AllowSubstitutions:=False _
> , LineEnding:=wdCRLF
> End Sub
>
> THANKS for any help!
>
> Gabriele
>
>
>
date: Wed, 22 Jun 2005 13:20:07 -0700
author: jonnycomeLately
|
|