从Excel工作簿中删除不需要的样式
我的Excel工作簿已达到了Excel风格的限制。我发现了VBA代码以删除未建立的,应用它并发现样式是内置的和“ sapbexstditem*”。
不幸地运行此代码没有效果。大约2周前,大约有36000种样式。 我不知道使用样式。如果我知道它们是如何创建的,我会尝试手动删除该样式,但首选VBA解决方案。
关于彼得
Sub RemoveTheStyles()
Dim style As style
Dim l_counter As Long
Dim l_total_number As Long
On Error Resume Next
l_total_number = ActiveWorkbook.Styles.Count
Application.ScreenUpdating = False
For l_counter = l_total_number To 1 Step -1
Set style = ActiveWorkbook.Styles(l_counter)
If (l_counter Mod 500 = 0) Then
DoEvents
Application.StatusBar = "Deleting " & l_total_number - l_counter + 1 & " of " & l_total_number & " " & style.Name
End If
If Not style.BuiltIn Then style.Delete
If Left(style.Name, 13) = "SAPBEXstdItem" Then
style.Delete
End If
Debug.Print style.Name
Next l_counter
Application.ScreenUpdating = True
Application.StatusBar = False
Debug.Print "READY!"
On Error GoTo 0
End Sub
My excel workbook has come upon a limit for excel Styles. I found VBA code to RemoveTheStyles that were not BuiltIn, applied it and found the Styles were BuiltIn and "SAPBEXstdItem*".
Running this code sadly had no effect. There are approx 36000 styles that got added about 2 weeks ago.
I don't know the styles were applied. If I knew how they were created I would try and remove the Style manually but a VBA solution would be preferred.
Regards Peter
Sub RemoveTheStyles()
Dim style As style
Dim l_counter As Long
Dim l_total_number As Long
On Error Resume Next
l_total_number = ActiveWorkbook.Styles.Count
Application.ScreenUpdating = False
For l_counter = l_total_number To 1 Step -1
Set style = ActiveWorkbook.Styles(l_counter)
If (l_counter Mod 500 = 0) Then
DoEvents
Application.StatusBar = "Deleting " & l_total_number - l_counter + 1 & " of " & l_total_number & " " & style.Name
End If
If Not style.BuiltIn Then style.Delete
If Left(style.Name, 13) = "SAPBEXstdItem" Then
style.Delete
End If
Debug.Print style.Name
Next l_counter
Application.ScreenUpdating = True
Application.StatusBar = False
Debug.Print "READY!"
On Error GoTo 0
End Sub
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您不应将
样式
作为变量名称之类的代码单词使用。这对我有用
You shouldn't use a code word like
style
as variable name.This works for me