|

楼主 |
发表于 2017-2-4 11:41
|
显示全部楼层
Sub 查看文件属性()
Dim sfilename As String
Dim stype As String
Dim itype As Integer
sfilename = Application.InputBox(prompt:="请输入文件名", _
Title:="输入文件名", Default:=ThisWorkbook.FullName, Type:=2)
If sfilename = "False" Then Exit Sub
With ActiveSheet
.Range(Cells(4, 1), Cells(7, 2)).Clear
.Cells(4, 1) = sfilename
.Cells(4, 1).Font.Bold = True
.Cells(5, 1) = "文件大小:"
.Cells(5, 2) = FileLen(sfilename) & "byte"
.Cells(6, 1) = "文件类型:"
itype = GetAttr(sfilename)
If itype And vbNormal = 0 Then
stype = "常规文件"
ElseIf itype And vnreadonly Then
stype = "只读文件"
ElseIf itype And vbHidden Then
stype = "隐藏文件"
ElseIf itype And vbSystem Then
stype = "系统文件"
ElseIf itype And vbArchive Then
stype = "备份文件"
ElseIf itype And vbDirectory Then
stype = "文件夹"
End If
.Cells(6, 2) = stype
.Cells(7, 1) = "最后修改时间:"
.Cells(7, 2) = FileDateTime(sfilename)
End With
End Sub |
|