Skip to content

Instantly share code, notes, and snippets.

@ZenLiuCN
Created March 29, 2024 09:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ZenLiuCN/a43e21c4fb2965faba7cf0c53b970aa5 to your computer and use it in GitHub Desktop.
Save ZenLiuCN/a43e21c4fb2965faba7cf0c53b970aa5 to your computer and use it in GitHub Desktop.
Dim iFile(1 To 100000) As String
Dim count As Integer
Sub xls2xlsx()
iPath = "D:\Dev\project\jvm\pharmacy\Ã×ÄÚÍøÅÅÃû\"
On Error Resume Next
count = 0
zdir iPath
For i = 1 To count
If iFile(i) Like "*.xls" And iFile(i) <> ThisWorkbook.FullName Then
MyFile = iFile(i)
FilePath = Replace(MyFile, ".xls", ".xlsx")
If Dir(FilePath, 16) = Empty Then
Set WBookOther = Workbooks.Open(MyFile)
Application.ScreenUpdating = False
ActiveWorkbook.SaveAs Filename:=FilePath, FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
WBookOther.Close SaveChanges:=False
Application.ScreenUpdating = True
End If
kill(MyFile)
End If
Next
End Sub
Sub zdir(p)
Set fs = CreateObject("scripting.filesystemobject")
For Each f In fs.GetFolder(p).Files
If f <> ThisWorkbook.FullName Then count = count + 1: iFile(count) = f
Next
For Each m In fs.GetFolder(p).SubFolders
zdir m
Next
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment