[RESOLVED] saveAs Export not working
objWorkbook.SaveAs FileName:="C:\Test.txt", FileFormat:=xlText
This is not working for me.
I get SaveAs method of workbook failed (1004)
I changed x|Text to one of many wdformats they fail too. ex(wdFormatDOSTextLineBreaks )
i need to export the spread sheet after making changes to a tab delimited file.
thanks.
Re: saveAs Export not working
Can you save it in any format at all using this code? Even a format you aren't interested it? Is there some problem with using the filename you have chosen?
zaza
Re: saveAs Export not working
no formats work. filename is temp.txt. if i leave off FileFormat:=xlText then is saves it with the new file name only not readable in notepad obviously.
Re: saveAs Export not working
I'm gonna mark this resolved. looks like i have to use this:
objWorkbook.SaveAs FileName:="C:\Test.txt", FileFormat:=3
i was not setting the constants. thanks for your help. any further info on this will still be helpful.
Re: [RESOLVED] saveAs Export not working
Hmmmm ... typical MegaShaft SNAFU. Here are some of the significant enumerations from '2003 xlFileFormat Class Members in the Object Browser(Hit <F2>). Of course, "3" is missing!
Code:
Debug.Print "xlSYLK", xlSYLK
Debug.Print "xlWKS", xlWKS
Debug.Print "xlWK1", xlWK1
Debug.Print "xlCSV", xlCSV
Debug.Print "xlDBF2", xlDBF2
Debug.Print "xlText", xlText
Debug.Print "xlTextMac", xlTextMac
Debug.Print "xlTextMSDOS", xlTextMSDOS
Debug.Print "xlTextWindows", xlTextWindows
Debug.Print "xlTextPrinter", xlTextPrinter
Debug.Print "xlUnicodeText", xlUnicodeText
Debug.Print "xlAddIn", xlAddIn
Debug.Print "xlCSVMac", xlCSVMac
Debug.Print "xlCSVMSDOS", xlCSVMSDOS
Debug.Print "xlCSVWindows", xlCSVWindows
Produces the following table:
Code:
xlSYLK 2
xlWKS 4
xlWK1 5
xlCSV 6
xlDBF2 7
xlText -4158
xlTextMac 19
xlTextMSDOS 21
xlTextWindows 20
xlTextPrinter 36
xlUnicodeText 42
xlAddIn 18
xlCSVMac 22
xlCSVMSDOS 24
xlCSVWindows 23
How did you find that "3" works?