D
David
I am working with Excel automation in an Access form.
I have hit a dead end with exporting a worksheet out of excel as a tab
deliminated text file. I am just new with Excel Automation
My code looks like this
Private Sub Export_Click()
Set xlApp = GetObject(, "Excel.Application")
' Take range, put it into sheet2 and then save sheet2 as Tab Deliminated
Txt file
With xlApp
.DisplayAlerts = False
.Sheets(1).Range("C11:C122").Select
.Selection.Copy
.Sheets(2).Select
.Sheets(2).Paste
'''''''The line below does not work?!''''''''
.ActiveWorkbook.SaveAs Filename:="L:\Universal\Data\FlightData.txt", _
FileFormat:=xlText, CreateBackup:=False,
ConflictResolution:=xlLocalSessionChanges
End With
xlApp.Quit
Set xlApp = Nothing
End Sub
The saveas line that I have marked above does not work. It is giving me a
"Run-time error '1004' : SaveAs method of Workbook class failed"
I have tried running the following code in an excel macro and it works
ActiveWorkbook.SaveAs Filename:="L:\Universal\Data\FlightData.txt", _
FileFormat:=xlText, CreateBackup:=False, _
ConflictResolution:=xlLocalSessionChanges
Is this not essentially the same code?
Why is this not working?
Thanks
David
I have hit a dead end with exporting a worksheet out of excel as a tab
deliminated text file. I am just new with Excel Automation
My code looks like this
Private Sub Export_Click()
Set xlApp = GetObject(, "Excel.Application")
' Take range, put it into sheet2 and then save sheet2 as Tab Deliminated
Txt file
With xlApp
.DisplayAlerts = False
.Sheets(1).Range("C11:C122").Select
.Selection.Copy
.Sheets(2).Select
.Sheets(2).Paste
'''''''The line below does not work?!''''''''
.ActiveWorkbook.SaveAs Filename:="L:\Universal\Data\FlightData.txt", _
FileFormat:=xlText, CreateBackup:=False,
ConflictResolution:=xlLocalSessionChanges
End With
xlApp.Quit
Set xlApp = Nothing
End Sub
The saveas line that I have marked above does not work. It is giving me a
"Run-time error '1004' : SaveAs method of Workbook class failed"
I have tried running the following code in an excel macro and it works
ActiveWorkbook.SaveAs Filename:="L:\Universal\Data\FlightData.txt", _
FileFormat:=xlText, CreateBackup:=False, _
ConflictResolution:=xlLocalSessionChanges
Is this not essentially the same code?
Why is this not working?
Thanks
David