Format file in excel from access

vipersmind

it can't be!
Local time
Tomorrow, 07:40
Joined
Dec 26, 2002
Messages
82
I am having to open a delimted .LAS file in excel as access will not import a file that is both TAB and SPACE delimited.
The following code is meant to open the delimented .LAS file in excel and save it as LasImport.txt.
I am getting the following error

Object does not support this property or method

Please help as i have tried many mnay variations and am receiving various messages in error :eek:

the part of the code oWb.Workbook.OpenText filename i copied from the excel vb.

Also Excel will not close! :mad: . It is still shows an instance in taskmanager.
I have read many posts on this and still can't fix it.

Regards
Cress

Code:
    Dim oXL As Excel.Application
    Dim oWb As Excel.Workbook
    Dim oWs As Excel.Worksheet
    Dim x As Integer
    Set oXL = New Excel.Application
    Set oWb = oXL.Workbooks.Add
    Set oWs = oWb.Sheets(1)
    strSelectedFile = Forms![frmGamma]![cbSelectGammaFile]

    ChDir "C:\database\imports\surtec\import"

    oWb.Workbook.OpenText filename:="C:\database\imports\surtec\import\"& strSelectedFile , _
        Origin:=437, StartRow:=1, DataType:=xlDelimited, TextQualifier:= _
        xlDoubleQuote, ConsecutiveDelimiter:=True, Tab:=True, Semicolon:=False, _
        Comma:=False, Space:=True, Other:=False, FieldInfo:=Array(Array(1, 1), _
        Array(2, 1), Array(3, 1), Array(4, 1), Array(5, 1), Array(6, 1), Array(7, 1), Array(8, 1), _
        Array(9, 1)), TrailingMinusNumbers:=True
        
    Set oWs = Nothing
    oXL.ScreenUpdating = True
    Kill "C:\database\imports\surtec\import\LasImport.txt"
    oWb.SaveAs "C:\database\imports\surtec\import\LasImport.txt"
    DoEvents
    oXL.DisplayAlerts = False
    For x = 1 To oXL.Workbooks.Count
        oXL.Workbooks(x).Saved = True
        oXL.Workbooks(x).Close False
    Next x
    Set oWb = Nothing
    oXL.Quit
    Set oXL = Nothing
 
Last edited:
I am getting same error message on similar problem. Have you already found out what is wrong? Please share your experience.
 
alarants I didn't find a solution exactly more a work around.
I changed the file type to .txt and ran a couple of import definitions - one using tab delim and the other space delim.
Then they were moved into one table.

change to .txt
Code:
OldName = "C:\database\imports\Gamma\DUSurvey\" & strSelectedFile: NewName = "C:\database\imports\Gamma\DUSurvey\import\" & strHoleIDCurrent & ".txt"
Name OldName As NewName    ' Move and rename file.

Not the most elegant thing I've ever done but at the time it was sufficient.
I now have a program that batch imports them

HTH
 

Users who are viewing this thread

Back
Top Bottom