J
JE McGimpsey
One way:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
On Error Resume Next
Me.Styles("myStyleName").Delete
On Error GoTo 0
End Sub
Use the On Error Resume Next in case the user deletes the style before
closing.
You could also prevent the error on startup in a similar way:
Private Sub Workbook_Open()
On Error Resume Next
With Me.Styles.Add("myStyleName")
.Font.Bold = True
.Font.Size = 16
End With
On Error GoTo 0
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
On Error Resume Next
Me.Styles("myStyleName").Delete
On Error GoTo 0
End Sub
Use the On Error Resume Next in case the user deletes the style before
closing.
You could also prevent the error on startup in a similar way:
Private Sub Workbook_Open()
On Error Resume Next
With Me.Styles.Add("myStyleName")
.Font.Bold = True
.Font.Size = 16
End With
On Error GoTo 0
End Sub