How can I know if Excel supports the fileformat constant?

G

Guest

My Excel version is Excel 2003. I tried the below code, and get a run-time
error.
ActiveWorkbook.SaveAs "C:\test.txt", xlTextMSDOS ' Error,
Err.Number=1004

I tested some fileformat constants, some are ok and some do not work.
ActiveWorkbook.SaveAs "C:\test.txt", 21 ' Error,
Err.Number=1004
ActiveWorkbook.SaveAs "C:\test.txt", xlCSVMSDOS ' Error,
Err.Number=1004
ActiveWorkbook.SaveAs "C:\test.txt", xlCurrentPlatformText 'OK
ActiveWorkbook.SaveAs "C:\test.txt", xlCSV 'OK

I donot know why. I guesss the reason is the environment on my computer. My
question is:
How can I know if Excel supports the fileformat constant before I use it?
 
G

Guest

Juile,

I tested the below code in my excel, and get a run-time error. I use
xlCurrentPlatformText and it is OK. Dave Peterson have tested the below code
in his excel, and it worked fine. I want know the reason, and want to avoid
error. Is there a way to estimate if it can work before I get a run-time
error?

Sub test()
ActiveWorkbook.SaveAs "C:\test.txt", 21 ' xlTextMSDOS, Error,
Err.Number=1004
End Sub

Best regards!
Liu Jianzhong
 
G

Guest

Julie,

I have a program developed using vba. The program will open an excel
workbook, and do many works such as putting some data into the workbook. A
user can select a file name and file type, and save the file. I use
workbook.saveas, but my excel does not support some constants and get a
run-time error. If I know what constants excel does not support, then I can
let user not to select them. But I do not find the way. In this situation, a
user will get a error message after many processing.

Best regards!
Liu Jianzhong
 
N

NickHK

Liu Jianzhong,
I guess you are working on a Chinese system.
I can confirm your code works fine on English W2K and Office2K, but errors
on (Traditional) Chinese W2K and Chinese Office.
Can't tell you why, but I guess you will just have to trap error or use a
format that you know works in all languages.

NickHK
 
G

Guest

Yes, I am working on a Simple Chinese system. OS is Windows XP Professional,
and Excel version is Microsoft Office Excel 2003 Professional Edition.

Thanks!
Liu Jianzhong
 

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