很难解释,但我的照片会很清楚。
我的 Excel 工作表在 a 列中有超链接,链接到要打开的文件,但如何从 l 列中的该文件中获取 lastmodifieddate
示例:a22 链接到文件 vimco,所以该文件的最后修改日期必须在 l22 中
也不是 a 列中的所有行都具有超链接,并且还包含一个空的或未链接的单元格,因此如果是这样,则在 l 列中不必显示任何内容,如果 a 为空白或未链接,则它必须为空白
它可以做一个公式吗?所以我输入 cell =moddate 然后显示日期现在可以了
好的,现在得到代码
Function GetDateTime(myCell As Range) As Date
Dim myHyperlink As Hyperlink
Dim Filename As String
Application.Volatile
On Error Resume Next
Set myHyperlink = myCell.Hyperlinks(1)
On Error GoTo 0
If Not myHyperlink Is Nothing Then
Filename = myHyperlink.Address
'If it is a relative address insert this workbook's path
If Not (Filename Like "\\*" Or Filename Like "[A-Z]:\*") Then
Filename = ThisWorkbook.path & "\" & Filename
End If
If Dir(Filename, vbNormal) <> "" Then
GetDateTime = FileDateTime(Filename)
Else
GetDateTime = ""
End If
Else
GetDateTime = ""
End If
End Function
但是现在第二件事,如果链接更改或者我打开我的工作簿或交换表没有更新 getdatetime 的值 - 可以修复吗?