Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / November 2007

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
TexPop - 25 Nov 2007 22:06 GMT
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.
Dave Peterson - 25 Nov 2007 22:31 GMT
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?

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

Signature

Dave Peterson

TexPop - 26 Nov 2007 20:24 GMT
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

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.