將這個子貼到一個新的宏,它應該給你你想要的。
Public Sub GetFileCount()
Dim count = 0
Dim i As Integer
For i = 1 To DTE.Windows.Count
If DTE.Windows().Item(i).Kind = "Document" Then
count = count + 1
End If
Next
MsgBox("File Count = " & count)
End Sub
編輯:
根據意見,我跑在VS2010宏並沒有得到中提到的不正確計數。嘗試進行以下更改以查看DTE中實際上被計爲「文檔」的內容。Windows集合:
Public Sub GetFileCount()
Dim count = 0
Dim i As Integer
Dim msg = ""
For i = 1 To DTE.Windows.Count
If DTE.Windows().Item(i).Kind = "Document" Then
count = count + 1
msg = msg & DTE.Windows().Item(i).Document.Name & vbCrLf
End If
Next
MsgBox("File Count = " & count & vbCrLf & msg)
End Sub
我想你可以編寫一個宏來完成它。 – 2010-09-22 19:19:52
爲什麼你打開了30多個文件,需要計數的是什麼?只是好奇,因爲我不記得每次有超過10個左右開放。 – Chuck 2010-09-23 12:02:17
@Chuck查看編輯 – hawbsl 2010-09-25 20:32:54