vba不打开压缩文件,从zip压缩包中读取文件属性

public arrfiles, n as integer
sub 批量提取压缩包内所有文件大小()
dim oapp as shell32.shell
set oapp = new shell32.shell
dim strfile as string
dim i as integer
set rng = application.inputbox(“请选择单元格区域”, type:=8)
if rng.count = 0 then exit sub
set rng = intersect(rng.parent.usedrange, rng)
for each cell in rng
if cell.offset(0, 3) = “zip” then
strfile = cell.hyperlinks(1).address
redim arrfiles(1 to 100)
searchfilesinzip strfile
end if
next
'range(“f2”).resize(1, ubound(arrfiles)) = arrfiles
range(“e1”).resize(ubound(arrfiles), 1) = application.worksheetfunction.transpose(arrfiles)
end sub

sub searchfilesinzip(strfile as string)
dim oapp as shell32.shell
dim filenameinzip, fd
dim ofolder as variant
set oapp = new shell32.shell
set ofolder = oapp.namespace(strfile).items
for each filenameinzip in ofolder
if filenameinzip.isfolder <> true then '判断是否为文件夹,是文件夹则肯能包含子文件
'debug.print filenameinzip.size & filenameinzip
'debug.print filenameinzip
n = n + 1
redim preserve arrfiles(1 to n + 100)
arrfiles(n) = filenameinzip.size & “;” & filenameinzip
else
strfile = filenameinzip.path '路径
searchfilesinzip strfile '子文件
end if
next
end sub
需要引用
Microsoft shell controls and automation

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值