延長の除去は、今の拡張機能の多様性を持っている ワークブック..ために実証されていることを詳細にできます。 。保存されていない新しいBook1には内線がありません 。ファイル
[コード]
機能WorkbookIsOpen(FWNa $、ブール= falseとオプションAnyExt)booleanとして
Dim wWB As Workbook, WBNa$, PD%
FWNa = Trim(FWNa)
If FWNa <> "" Then
For Each wWB In Workbooks
WBNa = wWB.Name
If AnyExt Then
PD = InStr(WBNa, ".")
If PD > 0 Then WBNa = Left(WBNa, PD - 1)
PD = InStr(FWNa, ".")
If PD > 0 Then FWNa = Left(FWNa, PD - 1)
'
' the alternative of using split.. see commented out below
' looks neater but takes a bit longer then the pair of instr and left
' VBA does about 800,000 of these small splits/sec
' and about 20,000,000 Instr Lefts per sec
' of course if not checking for other extensions they do not matter
' and to any reasonable program
' THIS DISCUSSIONOF TIME TAKEN DOES NOT MATTER
' IN doing about doing 2000 of this routine per sec
' WBNa = Split(WBNa, ".")(0)
'FWNa = Split(FWNa, ".")(0)
End If
If WBNa = FWNa Then
WorkbookIsOpen = True
Exit Function
End If
Next wWB
End If
エンド機能 [/コード]
ファイル拡張子はないが、名前にドットがある場合は機能しません。 –
いいえ?何が起こっているのか教えていただけますか?私はそれを逃している。 –
考えてみましょう。 InStrRevを使ってドットを探しています。ファイル名が「John.And.Mary.Spreadsheet」の場合は、「拡張子を隠す」オプションがオンになっているので、どうでしょうか?今では、ファイルが "John.And.Mary"であり、ファイル拡張子が "Spreadsheet"であると考えています。 –