Archive of Mr Excel Message Board


Back to Excel VBA archive index
Back to archive home



from a VB Macro how to save a excel worksheet as text file

Posted by Raja on December 19, 2000 11:16 AM
Hi all,


I need help to save an excel sheet as a plain text (either tab delimited or comma delimted) file.
This syntax is run as part of a VB Macro triggerred by a MS Outlook event.

I tried using the following syntax

mysheet.SaveAs FileName:="C:\RCK\DATA\IFILE.txt", FileFormat:=xlText, createBackup:=False

But it fails giving me an error like this..
1004 Save as Method of worksheet class failed

Would be thankful if anybody could suggest a way out.

Regards,
Rajaram


Check out our Excel VBA Resources

Re: from a VB Macro how to save a excel worksheet as text file

Posted by cpod on December 19, 2000 11:34 AM
I need help to save an excel sheet as a plain text (either tab delimited or comma delimted) file. This syntax is run as part of a VB Macro triggerred by a MS Outlook event.

change the xltext to xlcsv for a comma delimited file



Re: from a VB Macro how to save a excel worksheet as text file

Posted by Raja on December 19, 2000 11:45 AM
Thanks Cpod,

I tried with xlcsv still no luck !!

But if I try this as part of an Excel Macro it works just fine.

Could this be because the Macro is triggered from an MS Outlook event???

Thanks

Rgds,
Rajaram


Solution : from a VB Macro how to save a excel worksheet as text file

Posted by Raja on December 20, 2000 8:32 AM
In the above syntax for 'FileFormat:=xlText', the parameter xlText is not defined in Outlook. If I defile the xlText = 21 (MS-DOS Text format), then the file gets saved as text.

Rgds,
Rajaram




This archive is from the original message board at www.MrExcel.com.
All contents © 1998-2004 MrExcel.com.
Visit our online store to buy searchable CD's with thousands of VBA and Excel answers.
Microsoft Excel is a registered trademark of the Microsoft Corporation.
MrExcel is a registered trademark of Tickling Keys, Inc.