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
 

Some videos you may like

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.

Watch MrExcel Video

Forum statistics

Threads
1,122,564
Messages
5,596,863
Members
414,106
Latest member
Tigretto

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
Top