対象ブックが存在するか確認(Dir利用)

VB<span role="button" tabindex="0" data-code="'ブック確認 Sub 対象ブックが存在するか確認_D() Dim filePath As String filePath = "C:\Sample\Book1.xlsx" If Dir(filePath) “” Then Debug.Print “存在する” Else Debug.Print “存在しない” End If End Sub” style=”color:#D4D4D4;display:none” aria-label=”Copy” class=”code-block-pro-copy-button”>
'ブック確認
Sub 対象ブックが存在するか確認_D()
    Dim filePath As String
    filePath = "C:\Sample\Book1.xlsx"
    
     If Dir(filePath)  "" Then
        Debug.Print "存在する"
    Else
        Debug.Print "存在しない"
    End If
End Sub

コメント