[英]Excel keeps running slow using SmartArtLayout in VBA?
運行此代碼時 Excel 凍結,有沒有辦法阻止它? 甚至讓它凍結更短的時間。 代碼生成智能藝術層次結構
Sub Org()
'
' Org Macro
'
Dim ogSALayout As SmartArtLayout
Dim QNode As SmartArtNode
Dim QNodes As SmartArtNodes
Dim t As Integer
Set ogSALayout = Application.SmartArtLayouts(105) 'reference to organization chart
Set ogShp = ActiveWorkbook.ActiveSheet.Shapes.AddSmartArt(ogSALayout)
Set QNodes = ogShp.SmartArt.AllNodes
t = QNodes.Count
While QNodes.Count < t
QNodes(QNodes.Count).Delete
Wend
While QNodes.Count < Range("A1").End(xlDown).Row
QNodes.Add.Promote
Wend
For i = 1 To Range("A1").End(xlDown).Row
'Promote and demote nodes to put them at the proper level.
While QNodes(Range("A" & i)).Level < Range("C" & i).Value
QNodes(Range("A" & i)).Demote
Wend
'Copy the cell text to the node.
QNodes(Range("A" & i)).TextFrame2.TextRange.Text = Range("B" & i)
Next i
End Sub
這可能會有所幫助:
Sub Org()
Application.Screenupdating = False
'the rest of your code
Application.Screenupdating = True
End Sub
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.