Message 1 of 18

Not applicable
01-12-2015
04:38 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi
**using autocad 2015 and downloaded the latest VBA engine from autodesk.
I have a vba userform that lists all the layouts in the current dwg. I want to be able to delete the layouts when selected in the list box and i click submit.
Private Sub SubmitButton_Click() Dim MyArray() As Variant Dim i As Long Dim Cnt As Long With Me.Listbox1 Cnt = 0 For i = 0 To .ListCount - 1 If .Selected(i) = False Then Cnt = Cnt + 1 ReDim Preserve MyArray(1 To Cnt) MyArray(Cnt) = .List(i) End If Next i If Cnt > 0 Then If ThisDrawing.Layouts.Count > UBound(MyArray) Then 'Application.DisplayAlerts = False ThisDrawing.Layouts(MyArray).Delete 'Application.DisplayAlerts = True Call UpdateSheetList Else 'MsgBox "A workbook must contain at least one visible sheet.", vbExclamation End If Else 'MsgBox "Please select one or more sheets for deletion...", vbExclamation End If End With 'Unload Me End Sub Private Sub CancelButton_Click() 'unload form Unload Me End Sub Private Sub UserForm_Initialize() Call UpdateSheetList End Sub Private Sub UpdateSheetList() Dim PlotLayout As AcadLayout Dim PlotLayouts As AcadLayouts Listbox1.Clear Set PlotLayouts = ThisDrawing.Layouts For Each PlotLayout In PlotLayouts 'ThisDrawing.ActiveLayout = PlotLayout Listbox1.AddItem PlotLayout.Name Next End Sub
I am converting code from Excel so I think that's wehre my hang up is but i get the following code when I run it: invalid call or procedure. It pops up and i can select items but when i click submit it keeps erroring out.
Thanks in advance.
Solved! Go to Solution.