VBA and Excel: save from .csv to .xls

Nelson78

Well-known Member
Joined
Sep 11, 2017
Messages
526
Office Version
  1. 2007
I'm really sorry: error, please delete.
 
Last edited:

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
Hello everybody.

I'm in the following situation: after having found a .csv file in a folder (its length is always 98 and no others file could be 98), I've to save it in .xls

What instruction can I try?


Code:
Dim MyObj As Object, MySource As Object, File As Object
Dim MyFile As String
Set MyObj = CreateObject("Scripting.FileSystemObject")
Set MySource = MyObj.GetFolder("C:\Users\xxxxx.yyyy\Desktop\zzzzz\rrrr\")


For Each File In MySource.Files
    MyFile = File
        If Len(MyFile) = 98 Then 'length file is always 98 carachters
            Workbooks.Open (MyFile)  
            [COLOR="#FF0000"]'???????????????????????'[/COLOR]

            Exit For
        End If
Next File

Thank's.
 
Upvote 0
How about
Code:
            Workbooks.Open (MyFile)
            ActiveWorkbook.SaveAs Left(MyFile, Len(MyFile) - 4) & ".xls", 56
 
Upvote 0
I merged these two threads together, since you had deleted the question out of the one that had the reply.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top