Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default Prompt user to select a shape

Thanks Dave and Gary,

Both options are suitable and I will probably use a bit of both - thanks!



"Dave Peterson" wrote in message
...
Maybe you could show a dialog that allows the user to choose a shape (or
multiple shapes).

In xl2003, there is an icon that you can add to your favorite toolbar.

You can do it via:
tools|customize|commands tab|drawing category
look for "Select multiple objects"

In code, you can do this:

Option Explicit
Sub testme01()
Dim myCtrl As CommandBarControl
Dim myCB As CommandBar
Dim iCtr As Long

Set myCB = Nothing

Set myCtrl = Nothing
On Error Resume Next
Set myCtrl = Application.CommandBars.FindControl(ID:=3990)
On Error GoTo 0

If myCtrl Is Nothing Then
'not on any existing toolbar, so create a temporary toolbar
Set myCB = Application.CommandBars.Add(temporary:=True)
myCB.Visible = False
'add that button
Set myCtrl = myCB.Controls.Add(Type:=msoControlButton, ID:=3990)
End If

myCtrl.Execute
MsgBox TypeName(Selection)

Select Case LCase(TypeName(Selection))
Case Is = LCase("Range")
MsgBox "A range is selected"
Case Else
For iCtr = 1 To Selection.ShapeRange.Count
MsgBox Selection.ShapeRange(iCtr).Name
Next iCtr
End Select

'clean up
If myCB Is Nothing Then
'found it on an existing toolbar
Else
myCB.Delete
End If

End Sub

=========
Personally, I think I'd tell the users to select the object before the
code
starts. You can test the typename() of the selection to see if they have
a
Range selected.

If it is a Range, just yell at the user to select an object and start the
macro
once more.


MM User wrote:

Hi,

You can use the InputBox to prompt the user to enter some text or range -
is
it possible to also prompt the user to select a shape?

Thanks


--

Dave Peterson


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to Prompt a user to select a Folder. Akash Excel Programming 3 July 5th 07 05:02 PM
Prompt user to select directory Dan R. Excel Programming 3 March 2nd 07 07:22 PM
Prompt user to select a printer using a checkbox within a user Tom Ogilvy Excel Programming 0 January 10th 07 03:57 AM
how do I prompt the user to select a cell? [email protected] Excel Programming 1 December 19th 06 11:42 PM
Prompt user to select file with default file selected dialog Bruce Cooley Excel Programming 0 September 15th 03 06:43 AM


All times are GMT +1. The time now is 11:32 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"