' 判断名字为 sWorkbookName 的工作簿是否已经打开
Public Function IsOpenedWorkbook(ByVal xlApp As Application, _
ByVal sWorkbookName As String) As Boolean
Dim flag As Boolean
flag = False
If Len(sWorkbookName) = 0 Then
IsOpenedWorkbook = flag
Exit Function
End If
If xlApp.Workbooks.Count > 0 Then
Dim wb As Workbook
For Each wb In xlApp.Workbooks
If StrConv(sWorkbookName, vbUpperCase + vbWide) = StrConv(wb.Name, vbUpperCase + vbWide) Then ' 忽略字母大小写,忽略全角半角
flag = True
Exit For
End If
Next
End If
IsOpenedWorkbook = flag
End Function
在Excel中使用VBA判断指定名称的工作簿是否已经打开
于 2022-11-04 15:25:55 首次发布