Sub createfolder()
‘******檢查文件夾是否存在******
‘******如果不存在,就新建文件夾******
‘******并設(shè)置屬性為隱藏******
‘設(shè)置屬性:setAttr 文件(或文件夾) , 屬性
‘獲取屬性:getAttr 文件(或文件夾) , 屬性
‘******引用Microsoft Scripting Runtime******
Dim datafolder As String
Dim chfolder As Object
Set chfolder = CreateObject("scripting.filesystemobject")
datafolder = ThisWorkbook.Path & "\數(shù)據(jù)庫(kù)備份\"
If Not chfolder.FolderExists(datafolder) Then
chfolder.CreateFolder (datafolder)
SetAttr datafolder, vbHidden + vbReadOnly
MsgBox "The folder " & datafolder & " was created!"
End If
‘******文件和文件夾屬性******
‘常量 數(shù)值 屬性名稱(chēng)
‘vbNormal 0 普通文件(無(wú)其他屬性)
‘vbReadOnly 1 只讀,不可修改
‘vbHidden 2 隱藏
‘vbSystem 4 系統(tǒng)文件
‘vbDirectory 16 目錄
‘vbArchive 32 存檔
‘****************************
End Sub