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

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


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



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