Community
I am stuck. I am not sure where I am going wrong. I am trying to sort the drawing sheets by name alphanumerically. Looking for some input. I am trying to do it with a collection.
Sub Sort_DrawingSheets()
Dim drawingDoc As DrawingDocument
'Set drawingDoc = ThisDoc.Document
Set drawingDoc = ThisApplication.ActiveDocument
Dim sheet As sheet
Dim oSheets As Sheets
Set oSheets = drawingDoc.Sheets
Dim sheetsList As New Collection
Set sheetsList = New Collection
Dim vTemp As Variant
Dim browserPane As browserPane
Set browserPane = drawingDoc.BrowserPanes.item("Model")
For Each sheet In oSheets
sheetsList.Add (sheet.Name)
Next
For i = 1 To sheetsList.Count - 1
For j = i + 1 To sheetsList.Count
If sheetsList.item(i) > sheetsList.item(j) Then
vTemp = sheetsList.item(j)
sheetsList.Remove j
sheetsList.Add vTemp, vTemp, i
End If
Next j
Next i
For Each sheet In sheetsList
Dim sheetNode As BrowserNode
Set sheetNode = browserPane.GetBrowserNodeFromObject(sheet)
Dim bottomNode As BrowserNode
Set bottomNode = browserPane.TopNode.BrowserNodes.item(browserPane.TopNode.BrowserNodes.Count)
Call browserPane.Reorder(bottomNode, False, sheetNode)
Next
End Sub
Solved! Go to Solution.
Solved by inulobo. Go to Solution.
Can't find what you're looking for? Ask the community or share your knowledge.