With excel 2003 could open .csv file but not in excel 2007.

  • Thread starter Thread starter TexPop
  • Start date Start date
T

TexPop

I have succesfully downloaded .csv files with a macro in my Excell 2003 for
years, but that macro no longer works. I can't even open a .csv file with
Excel. Any suggestions.
 
I'd reregister excel

Close excel
windows start button|Run
excel /unregserver
windows start button|Run
excel /regserver

If that doesn't help, you may want to provide more info--what you did and what
happened when you did it?
 
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
 
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.

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,

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
 
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,

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top