0
這是我第一次寫宏,所以我不確定這個錯誤是什麼意思或如何解決它。任何人都可以提醒我嗎?任何幫助,將不勝感激。我想說我已經嘗試了一些解決方案,但正如我所說,這是我第一次不知道該怎麼嘗試。SharpDevelop中的宏錯誤 - 未聲明
Public Sub DeleteUnusedViews()
'define current document
Dim currentDoc As Document = Me.Application.ActiveUIDocument.Document
'get all views
Dim viewCollector = New FilteredElementCollector(currentDoc)
viewCollector.OfCategory(BuiltInCategory.OST_Sheets)
'create list of views to delete
Dim viewsToDelete As New List(Of View)
'loop through views and check if it's on a sheet
For Each curView As View In viewCollector
'check if view is a template
If curView.IsTemplate = False Then
'check if view can be added to sheet
If Viewport.CanAddViewToSheet(currentDoc, sheetCollector.FirstElement.Id, curView.Id) = True Then
'add view to delete list
viewsToDelete.Add(curView)
End If
End If
Next
'create transaction
Dim curTrans As New Transaction(currentDoc)
curTrans.Start("Delete unused views")
'delete views in list
For Each curViewToDelete As View In viewsToDelete
currentDoc.Delete(curViewToDelete.Id)
Next
'commit changes
curTrans.Commit
curTrans.Dispose
'alert the user
TaskDialog.Show("Deleted Views", "Deleted " & viewsToDelete.Count & " views.")
End Sub