SaveAs Text

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,
I would like to write an Excel VB script to save a word file as plain text
type format
thank you
 
Not that doing it from Excel is much different, but why aren't you writing
the macro in Word?

I have this word macro
Sub savetext()
Dim fName As String

fName = ActiveDocument.FullName
fName = Left(fName, Len(fName) - 4) + ".txt"

ActiveDocument.SaveAs FileName:=fName, FileFormat _
:=wdFormatText, LockComments:=False, Password:="",
AddToRecentFiles:=True _
, WritePassword:="", ReadOnlyRecommended:=False,
EmbedTrueTypeFonts:= _
False, SaveNativePictureFormat:=False, SaveFormsData:=False, _
SaveAsAOCELetter:=False
End Sub


It could be rewritten to work from Excel by creating a word object in excel
and the referencing Word

macro XLsaveWordText()
Dim fName As String
dim wordapp as object

Set wordapp = CreateObject("Word.Application")

fName = wordapp.ActiveDocument.FullName
fName = Left(fName, Len(fName) - 4) + ".txt"

wordapp.ActiveDocument.SaveAs FileName:=fName, FileFormat _
:=wdFormatText, LockComments:=False, Password:="",
AddToRecentFiles:=True _
, WritePassword:="", ReadOnlyRecommended:=False,
EmbedTrueTypeFonts:= _
False, SaveNativePictureFormat:=False, SaveFormsData:=False, _
SaveAsAOCELetter:=False
End Sub


I have not tested this from Excel but it should work.

Peter Richardson
 
Back
Top