SaveAs Text

G

Guest

Hello,
I would like to write an Excel VB script to save a word file as plain text
type format
thank you
 
G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top