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

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
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,214,524
Messages
6,120,049
Members
448,940
Latest member
mdusw

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