小编Kim*_*uba的帖子

If 语句 - msgbox

我现在正在尝试编写一个 IF 语句来说明以下内容:如果文件超过 5 天,则不要运行宏。如果超过 5 天,请运行宏。

我希望这是一个是或否的对话框。这是我的代码。请帮忙。我还在努力学习这个vba代码。

Sub LastModifiedFile()

'Function FileLastModified(strFullFileName As String)
    Dim fs As Object, f As Object, s As String, dtmodpath As String

    dtmodpath = "\\jdshare\pdcmaterials\5_Tools\FTP\Cancelled_Report.txt"
    Set fs = CreateObject("Scripting.FileSystemObject")
    Set f = fs.GetFile(dtmodpath)

    's = UCase(strFullFileName) & vbCrLf
    s = f.DateLastModified
    FileLastModified = s

    Set fs = Nothing: Set f = Nothing

Range("E5").Value = FileLastModified

'If FileExists(strFullName) Then
    'MsgBox FileLastModified(strFullName)
    'Else
        'MsgBox "File Older than 5 Years : " & vbNewLine & strFullName
    'End If …
Run Code Online (Sandbox Code Playgroud)

vba if-statement msgbox

2
推荐指数
1
解决办法
1万
查看次数

标签 统计

if-statement ×1

msgbox ×1

vba ×1