excel - 创建工作订单子文件夹以跟踪项目
问题描述
我使用 Excel 来跟踪我的项目。我在一个项目中收到多个工单。我需要在项目文件夹中创建多个文件夹。
我制定了一个宏来根据工单编号创建文件夹,但我需要工单文件夹中的子文件夹。
子文件夹保持不变,即输入和输出文件夹。
文件夹结构为项目文件夹>工单>输入和输出。
Sub Create_Folders()
Dim Rng As Range
Dim maxRows, maxCols, r, c As Integer
Dim path As Variant
Set Rng = Selection
maxRows = Rng.Rows.Count
maxCols = Rng.Columns.Count
For c = 1 To maxCols
r = 1
path = Application.InputBox("Enter the path where you want to create the folders", "Enter location")
Do While r <= maxRows
If Len(Dir(path & "\" & Rng(r, c), vbDirectory)) = 0 Then
MkDir (path & "\" & Rng(r, c))
On Error Resume Next
End If
r = r + 1
Loop
Next c
End Sub
解决方案
Dim path As Variant, fpath$
'...
fpath = path & Application.PathSeparator & Rng(r, c).Text
If Len(Dir(fpath, vbDirectory)) = 0 Then
MkDir fpath 'create main folder
'create subfolders
MkDir fpath & Application.PathSeparator & "Input"
MkDir fpath & Application.PathSeparator & "Output"
'...
End If
推荐阅读
- rest - 如何从 groovy curl 执行方法中检索 HTTP 代码
- cpu-architecture - 硬件平台中的数据危害
- docker - 从 docker-compose.yml 运行时容器未拾取现有卷或网络
- python - 结束程序后出现我的 tkinter 窗口
- reactjs - setTimeout 内的 setState 反应钩子
- node.js - 通过提供用户数据在 AWS 自动扩展中自动启动实例上的节点服务器
- django - Django表单验证没有函数调用
- git - 如何使用最新的 github 项目版本,而不是使用我已经更改的版本?
- python - 如何使用 pymongo 将新的值数组附加到 mongodb 中的现有数组文档?
- javascript - 资源未在 Chrome 中加载