[AccessD] Open CSV file using Excel object and save as Excel

Gustav Brock gustav at cactus.dk
Fri Oct 29 03:42:14 CDT 2004


Hi Paul

Try with

    Set objWB = objExcel.Workbooks.Open(FileName:=strLoc)

/gustav


> I have the following code in a database:
 
>     Dim objExcel As Excel.Application
>     Dim objWB As Excel.Workbook
>     Dim strSaveAs As String
 
>     Set objExcel = New Excel.Application
>     Set objWB = objExcel.Workbooks.OpenText(strLoc)    ' NOTE: strLoc is a
> path provided by the user
 
>     strSaveAs = Left(strLoc,((Len(Trim(strLoc))-4)) & ".xls"
 
>     objWB.SaveAs strSaveAs
 
>     objWB.Close
>     Set objWB = Nothing
>     objExcel.Quit
>     Set objExcel = Nothing
 
> This should be so simple but I get the following error message on the
> objExcel.Workbooks.OpenText line:
 
>     Expected Function or Variable




More information about the AccessD mailing list