Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Using Excel 2003. I'm trying to use VBA to select & open a csv file, search
for specific text (using the data in Cell A1 of my wb), etc. However, I am getting a Run-Time error 1004. Where am I going wrong? The code in part is as follows: Sub GetFile() Dim FileName As Variant FileName = Application.GetOpenFilename If FileName = False Then Debug.Print "user cancelled" Else Debug.Print "file selected: " & FileName End If Call ReadCSV2(myFileName, SearchData, DestSht) End Sub Sub ReadCSV2(ByVal myFileName, ByVal SearchData As String, ByVal DestSht) DestSht = "sheet1" With ThisWorkbook.Sheets(DestSht) SearchData = .Range("A1").Text End With Dim Data As String Dim Data1 As Date Dim Data2 As String Dim Data3 As String LastRow = ThisWorkbook.Sheets(DestSht) _ ..Range("A" & Rows.Count).End(xlUp).Row NewRow = LastRow + 1 RowCount = NewRow FName = "Temp" Do While FName < "" Workbooks.OpenText FileName:="Temp", DataType:=xlDelimited, Comma:=True Set CSVFile = ActiveWorkbook Set CSVSht = CSVFile.Sheets(1) 'check if data exists in column 77 Set c = CSVSht.Columns(77).Find(What:=SearchData, _ LookIn:=xlValues, LookAt:=xlWhole) If Not c Is Nothing Then FirstAddr = c.Address ,,,,,,etc I get the error code when it hits the line: Workbooks.OpenText FileName:="Temp", DataType:=xlDelimited, Comma:=True Can someone please help, I'm getting frustrated! Thanks -- Linda |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
runtime error '1004' application or object defined error | Excel Programming | |||
Run Time Error 1004: Application or Object Defined Error | Excel Programming | |||
Run Time 1004 Error: Application or Object Difine Error | Excel Programming | |||
Error 1004, Application-definded or object-defined error | Excel Programming | |||
run-time error '1004': Application-defined or object-deifined error | Excel Programming |