VBA converting .csv files to .xlsx in a new location.

youngseolwha

New Member
Joined
Mar 16, 2016
Messages
2
Hello,
I'm using a vba in another program, not Excel.
I want to make a test.csv file in C:/csv_test -> (change) test.xls file in C:/csv_test/Excel_Files.

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Public Sub LeftClickDown_Default0(obElem As Element)

Dim strFile As String, strDir As String, strOut_Dir As String, myNewFileName As String

strDir = "C:\csv_test\" 'location of csv files
strOut_Dir = "C:\csv_test\Excel_Files\" 'location of xls files
strFile = Dir(strDir & "*.csv")

Do While strFile <> ""

Set wb = Workbooks.Open(FileName:=strDir & strFile, Local:=True)

With wb
.SaveAs Replace(wb.FullName, ".csv", ".xls"), 56 'UPDATE:
.Close True
End With
Set wb = Nothing
strFile = Dir

Loop


End Sub
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

But this code has an error.
Message box ( Run-time error '424' : object required)
I using vba version 7.1 and Excel 2013
Is there anyone help me?
Plz
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying

Forum statistics

Threads
1,214,588
Messages
6,120,412
Members
448,960
Latest member
AKSMITH

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