G
Guest
I am trying to open and save an imported .csv file as an excel workbook, but
the "saveas" method returns the error message "saveas method of workbook
class failed." The code is as follows:
Private Sub btnTest_Click()
Dim oApp As Object
Dim oSource As Object
Dim strSource As String
Dim strDest As String
Set oApp = CreateObject("Excel.Application")
oApp.Visible = True
oApp.UserControl = True
strSource = "C:\Documents and Settings\ccrcsg1dxm\My
Documents\Excelwrk\Impts\CCW_VNDR_PYMNT_STATUS_ACCTG_DT.csv"
strDest = "C:\Documents and Settings\ccrcsg1dxm\My
Documents\Excelwrk\Impts\apimpt"
Set oSource = oApp.workbooks.Open(strSource)
oSource.SaveAs Filename:=strDest, _
FileFormat:=xlExcel9795, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
oSource.Close
oApp.Close
End Sub
Does "saveas" have to be run inside Excel? Can this procedure be executed
in the background, without making excel visible.
Thanks,
DM
the "saveas" method returns the error message "saveas method of workbook
class failed." The code is as follows:
Private Sub btnTest_Click()
Dim oApp As Object
Dim oSource As Object
Dim strSource As String
Dim strDest As String
Set oApp = CreateObject("Excel.Application")
oApp.Visible = True
oApp.UserControl = True
strSource = "C:\Documents and Settings\ccrcsg1dxm\My
Documents\Excelwrk\Impts\CCW_VNDR_PYMNT_STATUS_ACCTG_DT.csv"
strDest = "C:\Documents and Settings\ccrcsg1dxm\My
Documents\Excelwrk\Impts\apimpt"
Set oSource = oApp.workbooks.Open(strSource)
oSource.SaveAs Filename:=strDest, _
FileFormat:=xlExcel9795, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
oSource.Close
oApp.Close
End Sub
Does "saveas" have to be run inside Excel? Can this procedure be executed
in the background, without making excel visible.
Thanks,
DM