【WPS如何快速创建本月每天命名的文件夹】分享给互联网技能从业者学习和参考。
1、使用宏:WPS支持使用宏来快速创建文件夹,可以在宏编辑器中编写宏,定义一个函数名为MakeMonthFolders,代码如下:Sub MakeMonthFolders()
Dim startDate As Date, endDate As Date
Dim folderName As String
Dim Path As String
Path = ThisDocument.Path
startDate = DateSerial(Year(Now), Month(Now),1)
endDate = DateSerial(Year(Now),Month(Now)+1,0)
For i = startDate To endDate
folderName = Format(i, "d")
MkDir Path + "" + folderName
Next
End Sub
2、使用WPS表格:可以通过在WPS表格中构造本月每天的日期,然后遍历构造出的日期来实现快速创建文件夹的功能。如下图所示:(1)首先在WPS表格中将本月的开始日期和结束日期按日期格式填入B2和B3;
(2)点击B1单元格,输入=B2;
(3)然后拖动B1单元格的右下角小方块,填充至B3,此时B1~B30单元格中会有本月每天的日期了;
(4)然后新建一个VBA(宏)代码,编写宏,定义一个函数名为MakeMonthFolders,代码如下:
Sub MakeMonthFolders()
Dim Path As String
Path = ThisDocument.Path
For i = 1 To 30
MkDir Path + "" + Range("B" & CStr(i))
Next
End Sub
3、使用VBA:可以编写VBA代码,定义一个函数名为MakeMonthFolders,代码如下:Sub MakeMonthFolders()
Dim startDate As Date, endDate As Date
Dim folderName As String
Dim Path As String
Path = ThisDocument.Path
startDate = DateSerial(Year(Now), Month(Now),1)
endDate = DateSerial(Year(Now),Month(Now)+1,0)
For i = startDate To endDate
folderName = Format(i, "d")
MkDir Path + "" + folderName
Next
End Sub