打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
怎么通过vba获取一个目录下的所有文件夹名称、大小、文件夹中所有文档数量
如何通过vba获取一个目录下的所有文件夹名称、大小、文件夹中所有文档数量?
如何通过vba获取一个目录下的所有文件夹名称、大小、文件夹中所有文档数量?
例如:
vb-vba1
              -1.txt
              -2.txt
    -vba2
              -3.txt
    -vba3

需要的结果是:
文件夹名称         文件夹大小     文件夹文档数量
vba1                                                             2
vba2                                                             1
vba3                                                             0


------解决方案--------------------
<hta>
<head>
<META HTTP-EQUIV= "pragma " CONTENT= "no-cache ">
<META HTTP-EQUIV= "Cache-Control " CONTENT= "no-cache, must-revalidate ">
<META HTTP-EQUIV= "expires " CONTENT= "0 ">
<title> 命名程序 </title>
</head>
<body scroll= "auto " style= "border:none; color:green; " bgcolor=black topmargin=0 leftmargin=0 rightmargin=0 bottommargin=0 >
<textarea id=show rows=10 style= "width:100%; "> </textarea>
<textarea id=dofile rows=20 style= "width:100%; " title=请在这输入处理文件的方法> function (path){

请在这输入处理文件的方法,其它不变。

} </textarea>

源文件夹 <input id= "sourcefolder " type=file> <br> <input type=button value=获取全部文件夹 onclick= "getallfolder(sourcefolder.value) ">

<input type=button value=处理所有文件 onclick= "doallfile() ">
<input type=button value=清除 onclick= "showtxt( '已清除所有定时 '); clearTimeout(fsotime) ">
<SCRIPT language= "javascript ">
<!--

var fso = new ActiveXObject( "Scripting.FileSystemObject ");
var runtime = 1;
var foldersarray;
var fsotime;
var nowi;
var fp;
var theno;
var mydofile;

function showtxt(txt)
{
show.focus();
show.value += txt + "\n ";
}

function reportError(msg,url,line)
{
alert( "当前页的脚本发生错误: \n\n信息: " + msg + "\n\n行: " + line);
return true;
}

window.onerror = reportError;

function getallfolder(path)
{
 if ( fso.folderExists(path) == false)
   {
showtxt( "出错啦!\n[ " + path + "] 文件夹不存在! ");
return false;
}

if(fso.DriveExists(path))
{
path += "\\ ";
}

mygetfolder(path);
}

function mygetfolder(path){//自己递归时没参数

if(path != undefined)
{
clearTimeout(fsotime);
fp = null;
nowi = -1;
theno = 1;
foldersarray = new Array(fso.getFolder(path).path);
showtxt( "开始获取文件夹...\n " + (theno++) + ": " + fso.getFolder(path).path);
}

try
{
if(fp == null) 
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
Excel VBA中文件夹操作代码小集
VBA提取文件目录并超链接
VBA实例:Word文档内容搜索器,文件遍历,当前位置下子文件夹遍历(by daode12...
Excel·VBA文件重命名、移动
VBA FSO 文件操作系统
FSO(10):VBA循环创建多层文件夹
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服