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

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
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,223,908
Messages
6,175,304
Members
452,633
Latest member
DougMo

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