Delete REGAPPs with VBA

Delete REGAPPs with VBA

Anonymous
Not applicable
814 Views
4 Replies
Message 1 of 5

Delete REGAPPs with VBA

Anonymous
Not applicable
Does anyone have the VB/VBA code to delete unused Regapps? Similar to
the -PURGE Regapp command, but I would like to do it with VBA. I know there
are lisp routines out there, but all my other purge routines are done in VBA
and I would like to add this one.

I have also tried the Sendcommand... but it locks up sometimes...

Thanks,
Jim Shipley
0 Likes
815 Views
4 Replies
Replies (4)
Message 2 of 5

Anonymous
Not applicable
Here's some code I found to check for invalid reg apps.
You should be able to this modify to your needs...

[code]
'Verify registered apps when drawing loads
Private Sub VerifyRegistered_Apps()
Dim oRegApp As AcadRegisteredApplication
Dim oRegApps As AcadRegisteredApplications
Dim colBadApps As Collection
Dim strMSG As String
Dim i As Integer

'get the current collection of registered apps
Set oRegApps = ThisDrawing.RegisteredApplications

' start a new collection for bad apps
Set colBadApps = New Collection

' review each registered application
For Each oRegApp In oRegApps
'Debug.Print oRegApp.Name
' if there's a "*" in the name, damn good chance it's BAD!
If InStr(1, oRegApp.Name, "*") > 0 Then
colBadApps.Add oRegApp.Name
End If
Next

' if we found some bad apps, report them!
If colBadApps.Count > 0 Then
'build list of bad ones
For i = 1 To colBadApps.Count
strMSG = strMSG & colBadApps.Item(i) & vbNewLine
Next

'display the bad news
MsgBox "There's a good chance this drawing has corruputed data!" & vbNewLine & _
"INVALID REGISTERED APPS FOUND!" & vbNewLine & _
strMSG
End If

Set colBadApps = Nothing
Set oRegApp = Nothing
Set oRegApps = Nothing


End Sub
[/code]
0 Likes
Message 3 of 5

Anonymous
Not applicable
Thanks!

wrote in message news:[email protected]...
Here's some code I found to check for invalid reg apps.
You should be able to this modify to your needs...

[code]
'Verify registered apps when drawing loads
Private Sub VerifyRegistered_Apps()
Dim oRegApp As AcadRegisteredApplication
Dim oRegApps As AcadRegisteredApplications
Dim colBadApps As Collection
Dim strMSG As String
Dim i As Integer

'get the current collection of registered apps
Set oRegApps = ThisDrawing.RegisteredApplications

' start a new collection for bad apps
Set colBadApps = New Collection

' review each registered application
For Each oRegApp In oRegApps
'Debug.Print oRegApp.Name
' if there's a "*" in the name, damn good chance it's BAD!
If InStr(1, oRegApp.Name, "*") > 0 Then
colBadApps.Add oRegApp.Name
End If
Next

' if we found some bad apps, report them!
If colBadApps.Count > 0 Then
'build list of bad ones
For i = 1 To colBadApps.Count
strMSG = strMSG & colBadApps.Item(i) & vbNewLine
Next

'display the bad news
MsgBox "There's a good chance this drawing has corruputed data!" &
vbNewLine & _
"INVALID REGISTERED APPS FOUND!" & vbNewLine & _
strMSG
End If

Set colBadApps = Nothing
Set oRegApp = Nothing
Set oRegApps = Nothing


End Sub
[/code]
0 Likes
Message 4 of 5

Anonymous
Not applicable
"Thanks!"
I'll take it from that you'll have no trouble making it work for you.

"I have also tried the Sendcommand... but it locks up sometimes..."
I'm sure you were using this out of desperation :). It's certainly a "worst case scenario".
0 Likes
Message 5 of 5

Anonymous
Not applicable
I have also found out that the Autodesk arx for this should be used. See:
http://autodesk.blogs.com/between_the_lines/2004/12/layer_filter_an.html

Jim


wrote in message news:[email protected]...
"Thanks!"
I'll take it from that you'll have no trouble making it work for you.

"I have also tried the Sendcommand... but it locks up sometimes..."
I'm sure you were using this out of desperation :). It's certainly a "worst
case scenario".
0 Likes