#1   Report Post  
Posted to microsoft.public.excel.programming
dan dan is offline
external usenet poster
 
Posts: 866
Default SaveAs Text

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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 119
Default SaveAs Text

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

"Dan" wrote:

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


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro syntax: SaveAs Filename=ActiveCell.Text . BUT to a specified folder [email protected] Excel Programming 3 August 1st 07 03:32 PM
runtime error 1004 saveas text file Janis Excel Programming 2 September 1st 06 11:11 PM
SaveAs text file from VBA Getting Error JeepNC Excel Programming 1 January 28th 05 10:20 PM
saveas fixed text for unix jeffP Excel Programming 10 September 8th 04 01:11 PM


All times are GMT +1. The time now is 02:26 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"