----------------------------------------------------------------
Sub Sample7()
Dim buf As String
Dim wb As Workbook
Dim OpenFile As String
Dim OpenFilename As String
Dim CutPoint As Long
Dim FilePath As String
Dim FileName As String
Dim FileLen As Long
OpenFile = Application.GetOpenFilename("Microsoft Excelブック,*.xls")
If OpenFile <> "False" Then
CutPoint = InStrRev(OpenFile, "\")
FileLen = Len(OpenFile) - CutPoint
OpenFilename = Right(OpenFile, FileLen)
For Each wb In Workbooks
If wb.Name = OpenFilename Then
MsgBox OpenFilename & vbCrLf & "はすでに開いています", vbExclamation
Exit Sub
End If
Next wb
Workbooks.Open OpenFile
Else
MsgBox OpenFilename & vbCrLf & "は存在しません", vbExclamation
Exit Sub
End If
End Sub
----------------------------------------------------------------
最終更新:2012年02月11日 13:55