Dave,
Thank you so much for responding to my query. After I submitted it, I found
many of the strings on cvs files and am still unable to read the cvs files.
I did run “excel / unregserver” and “excel / regserver” as you suggested,
and I got back “unregserver.xlsx could not be found. Check the spelling …….”
after Excel opened. I registered my 2007 Office when I loaded it.
Following is the code I have used successfully in Excel 2003. It doesn't
run on Excel 2007.
I would appreciate any help you can give me.
Jim
'******************************************************
Function RowCountYX(ReferenceCell As String, RowOffset As Integer, ColOffset
As Integer) As Integer
'Returns the number of rows below the ReferenceCell (offset by ColOffset and
RowOffset)
'that are not blank. Note: Cell can contain calculation error to be counted.
Dim Blank As Boolean
RowCountYX = 0
Blank = False
Do
X = Range(ReferenceCell).Offset(RowOffset + RowCountYX + 1,
ColOffset).Value
If Not IsError(X) Then
If X = "" Then 'Check if cell is blank
Blank = True
RowCountYX = RowCountYX - 1
End If
End If
RowCountYX = RowCountYX + 1
Loop Until Blank
End Function
Sub LoadFundPrices()
Dim nRows As Integer
Dim CopyRange As String
Dim Name As String
Dim HomeSheet As String
Dim MainFile As String
HomeSheet = ActiveSheet.Name
MainFile = ActiveWorkbook.Name
Name = "C:\Junk\Funds.csv"
Workbooks.Open FileName:=Name 'fails with following message:
'c:\Junk\Funds.csv could not be found. Check the spelling.....
‘I checked and double checked the existence of the .csv file in c:\Junk.
nRows = RowCountYX("A1", 0, 0)
CopyRange = "A1:J" & Trim(Str(nRows))
Range(CopyRange).Select
Selection.Copy
Windows(MainFile).Activate
Sheets("DownLoad").Select
Range("A1").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Windows("Funds.csv").Activate
Application.CutCopyMode = False
ActiveWindow.Close
End Sub
> I'd reregister excel
>
[quoted text clipped - 10 lines]
> > years, but that macro no longer works. I can't even open a .csv file with
> > Excel. Any suggestions.
Dave Peterson - 26 Nov 2007 20:59 GMT
First, I didn't know that you were using code to open your .csv files. I
assumed that the problem was occurring when you double clicked on the file name
in windows explorer.
And even though re-registering excel won't help your code, you didn't follow the
instructions close enough.
> > Close excel
> > windows start button|Run
> > excel /unregserver
> > windows start button|Run
> > excel /regserver
There is a space character after Excel and then no space embedded in
/unregserver and no space in /regserver.
As for your code, I bet you don't have a file named:
C:\junk\funds.csv
I'd double check--and make sure you're looking at all the the filename--maybe
you have the extension hidden (it's a windows option).
The real filename could be:
C:\junk\funds.csv.xls
(or any other known extension)
But you're not seeing that last extension.
> Dave,
>
[quoted text clipped - 83 lines]
> >
> > Dave Peterson

Signature
Dave Peterson
TexPop - 27 Nov 2007 01:09 GMT
Dave,
You solved my problem! I did change my Windows option to show all file
extensions. My file "Funds.csv" was in fact "Funds.csv.xls". I am not sure
how the .xls was added, but when I renamed the file to "Funds.csv" the code
worked fine. When I downloaded the .csv files from the internet everything
went like it was supposed to.
I can't tell you how much I appreciate your straightening me out. I am a 73
yr old novis at this programming game.
Jim
> First, I didn't know that you were using code to open your .csv files. I
> assumed that the problem was occurring when you double clicked on the file name
[quoted text clipped - 110 lines]
> > >
> > > Dave Peterson
Dave Peterson - 27 Nov 2007 01:43 GMT
Whew!
Glad you got it working.
As an aside, I think it's always best to show those extensions. Some bad people
try to send files with names like:
ThisIsAPicture.jpg.vbs
or
ThisIsAPicture.jpg.exe
When you click on the filename, the .vbs or .exe runs and that can cause damage.
> Dave,
>
[quoted text clipped - 127 lines]
> >
> > Dave Peterson

Signature
Dave Peterson