LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default Error 1004-application or object error

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
runtime error '1004' application or object defined error Janis Excel Programming 4 November 18th 09 03:01 PM
Run Time Error 1004: Application or Object Defined Error BEEJAY Excel Programming 4 October 18th 06 04:19 PM
Run Time 1004 Error: Application or Object Difine Error BEEJAY Excel Programming 0 October 17th 06 10:45 PM
Error 1004, Application-definded or object-defined error Mirco Wilhelm[_2_] Excel Programming 9 January 7th 06 04:56 PM
run-time error '1004': Application-defined or object-deifined error [email protected] Excel Programming 5 August 10th 05 09:39 PM


All times are GMT +1. The time now is 09:44 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"