|
-
Feb 2nd, 2005, 11:07 AM
#1
Thread Starter
New Member
Excel SaveAs from Access Error
I have the following code running trying to open an excel sheet, change the formatting on a column and then save the sheet as a text file. When it gets to the SaveAs I get an error message: SaveAs Method of Workbook Class Failed. I have narrowed it down to the FileFormat:xlText as the culprit, if you take out the file format it saves fine, but the file is just garbage. Any ideas as to what the problem is?
Thanks!
Dim xlx As Object, xlw As Object, xls As Object, xlc As Object
Set xlx = CreateObject("excel.application")
xlx.Visible = True
Set xlw = xlx.workbooks.Open("C:\book1.xls")
Set xls = xlw.worksheets("sheet1")
xls.Columns("K:K").NumberFormat = "0"
xlw.SaveAs Filename:="C:\Book1.txt", _
FileFormat:=xlText, CreateBackup:=False
Set xlc = Nothing
Set xls = Nothing
xlw.Close False
Set xlw = Nothing
xlx.Quit
Set xlx = Nothing
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|