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

Paul Hartland (ISHARP) paul.hartland at isharp.co.uk
Fri Oct 29 08:15:11 CDT 2004


Yeah the path is returned as follows

C:\PNProject\Critpath_Fin.csv

Paul

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Gustav Brock
Sent: 29 October 2004 13:51
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] Open CSV file using Excel object and save as Excel


Hi Paul

This works all the time for me.
Something else must be going on at your side.
Are you sure the filename is stated correctly?

Put in

  Debug.Print strLoc

and read.

/gustav


> Gustav,

> Tried the line you sent and got the following error message now:

>         Method 'Open' of object 'Workbooks' failed

> Any ideas ?

> Paul

> -----Original Message-----
> From: accessd-bounces at databaseadvisors.com
> [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Gustav 
> Brock
> Sent: 29 October 2004 09:42
> To: Access Developers discussion and problem solving
> Subject: Re: [AccessD] Open CSV file using Excel object and save as Excel


> 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

-- 
_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com




More information about the AccessD mailing list