Not applicable
07-17-2015
07:11 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have this code. The purpose is to apply attributes to a selection. I want to eventually have a way to prompt a selection but for right now I just need to post an error message if the code is run without a prior selection. Then close the userform. I added "unload me" but wind up w/ errors and it doesn't seem to do anything. How do I get the userform to close after prompting that nothing was selected?
Private Sub UserForm_Initialize() With cbxSystem .AddItem ("Furniture") .AddItem ("Audio") .AddItem ("Electrical") .AddItem ("Hello Kitty") End With Set ocSelected = ThisApplication.TransientObjects.CreateObjectCollection If TestIfNoneSelected() Then MsgBox ("Nothing selected") 'Unload Me 'Exit Sub Else Call GetSelectedObjects(ocSelected) End If End Sub Private Function TestIfNoneSelected() As Boolean Dim docCurrent As Document Set docCurrent = ThisApplication.ActiveDocument If docCurrent.SelectSet.Count < 1 Then TestIfNoneSelected = True Else TestIfNoneSelected = False End If End Function
Solved! Go to Solution.