|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
带参数的过程.rar
(15.97 KB, 下载次数: 10)
以下一段代码作用为删除过多单元格格式,请问这种带参数的过程该如何运行。
- Sub RemoveTheStyles(control As IRibbonControl)
- Dim s As Style, i As Long, c As Long
- On Error Resume Next
- If ActiveWorkbook.MultiUserEditing Then
- If MsgBox("You cannot remove Styles in a Shared workbook." & vbCr & vbCr & _
- "Do you want to unshare the workbook?", vbYesNo + vbInformation) = vbYes Then
- ActiveWorkbook.ExclusiveAccess
- If Err.Description = "Application-defined or object-defined error" Then
- Exit Sub
- End If
- Else
- Exit Sub
- End If
- End If
- c = ActiveWorkbook.Styles.Count
- Application.ScreenUpdating = False
- For i = c To 1 Step -1
- If i Mod 600 = 0 Then DoEvents
- Set s = ActiveWorkbook.Styles(i)
- Application.StatusBar = "Deleting " & c - i + 1 & " of " & c & " " & s.Name
- If Not s.BuiltIn Then
- s.Delete
- If Err.Description = "You cannot use this command on a protected sheet. To use this command, you must first unprotect the sheet (Review tab, Changes group, Unprotect Sheet button). You may be prompted for a password." Then
- MsgBox Err.Description & vbCr & "You have to unprotect all of the sheets in the workbook to remove styles.", vbExclamation, "Remove Styles AddIn"
- Exit For
- End If
- End If
- Next
- Application.ScreenUpdating = True
- Application.StatusBar = False
- End Sub
-
复制代码
|
|