我创建了一个从压缩文件夹中解压缩文件的子文件
Private Sub UnZipFile(Folder As String, FileName As String)
Dim oSHApp, oSHFolder ' as object
Dim sSrc, sDest ' as string
Dim fName As String
Set oSHApp = CreateObject("Shell.Application")
sSrc = Folder & FileName
sDest = Folder
Set oSHFolder = oSHApp.Namespace(sSrc)
oSHApp.Namespace(sDest).CopyHere oSHFolder.Items
End Sub
我想在提取后重命名oSHFolder.Items
,最优化的方法是什么?
编辑:文件名不是静态的,我不能事先知道它的名字
谢谢
答案 0 :(得分:2)
由于您只有一个文件,因此只需要一行:
Const FinalName As String = "YourFileName.txt"
<snip>
Set oSHFolder = oSHApp.Namespace(sSrc)
oSHApp.Namespace(sDest).CopyHere oSHFolder.Items
Name sDest & "\" & oSHFolder.Items.Item(0).Name As sDest & "\" & FinalName