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
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