Public Declare Function SetTimer Lib "user32.dll" (ByVal hwnd As Long, ByVal nIDEvent As Long, _
ByVal uElapse As Long, ByVal lpTimerFunc As Long) As Long
Public Declare Function KillTimer Lib "user32.dll" (ByVal hwnd As Long, ByVal nIDEvent As Long) As Long
Public Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Sub DeleteDefinedNames()
Dim beforeReferenceStyle As Variant
beforeReferenceStyle = Application.ReferenceStyle
Dim timerID As Long
timerID = SetTimer(0, 0, 100, AddressOfTimerProc)
If beforeReferenceStyle = xlR1C1 Then
Application.ReferenceStyle = xlA1
Else
Application.ReferenceStyle = xlR1C1
End If
Dim n As Name
For Each n In ActiveWorkbook.Names
If Not n.Name Like "*!Print_Area" And _
Not n.Name Like "*!Print_Titles" Then
n.Delete
End If
Next
Application.ReferenceStyle = beforeReferenceStyle
KillTimer 0, timerID
End Sub
Private Function getRandomString(min As Long, max As Long) As String
Dim s As String
Dim i As Long
max = Int(max * Rnd)
For i = 0 To min + max
Randomize
s = s & Chr(65 + Int(26 * Rnd))
Next
getRandomString = s
End Function
End Function