Saveas

Timtropolis

Registered User.
Local time
Today, 15:30
Joined
Jun 17, 2004
Messages
84
Greetings,

I am having some trouble using the "save as" function in my code (below).

obxls.saveas filename:="C:\Access_databases\Exports\NewRisks.csv"

I am trying to automate the process of saving a xls file to a .csv file and everytime I get to this line of code I get an error message stating:

Runtime error 438, Object doesn't support this property or method.

obxls is dimmed as an object.

I'm a little confused here and was wondering if someone else has experienced this. I've looked in some of the other help items here and have not found
what I need. I've seen examples that look just like mine so I'm assuming I have coded correctly. Any ideas?

TIA,
Tim
 
well let me include the code so you can see what i'm doing here. The code is legitimate, all I want to know is how to code for the SAVEAS.

Code:
    Dim dbs As Database
    Dim obxls As Object
    Dim boolXL As Boolean
    
    Set dbs = CurrentDb
    
    If fIsFileDIR("C:\Access_databases\Exports\NewRisks.csv") = -1 Then
        Kill "C:\Access_databases\Exports\NewRisks.csv"
    End If
    
    If fIsAppRunning("Excel") Then
        Set obxls = GetObject(, "Excel.Application")
        boolXL = False
    Else
        Set obxls = CreateObject("Excel.Application")
        boolXL = True
    End If
    
    
    'obxls.Visible = True
    obxls.workbooks.Open filename:="C:\Access_databases\Exports\RiskAssertion_Breakout"
    obxls.SaveAs filename:="C:\Access_databases\Exports\NewRisks.csv"
    
    
    obxls.Quit
    Set obxls = Nothing

Hopefully this will help
 
Following Pat's suggestion of explicitly typing the object and then using intellisense would probably lead you to realise that your statement is trying to save the excel application. You need to save the workbook. If you want to do it this way, set an object reference to the workbook, then


objXLWorkbook.SaveAs FileName:="C:\Access_databases\Exports\NewRisks.csv", FileFormat:=xlCSV

HTH regards

John
 

Users who are viewing this thread

Back
Top Bottom