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

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Prompt user to select a shape

Sub shapepicker()
x = Application.InputBox(prompt:="enter the shape name: ", Type:=2)
ActiveSheet.Shapes(x).Select
End Sub

The user would enter something like Oval 1
--
Gary''s Student - gsnu200800


"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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default Prompt user to select a shape

Apologies but I need the user to actually select the shape not enter the
name - is this possible?

thanks


"Gary''s Student" wrote in message
...
Sub shapepicker()
x = Application.InputBox(prompt:="enter the shape name: ", Type:=2)
ActiveSheet.Shapes(x).Select
End Sub

The user would enter something like Oval 1
--
Gary''s Student - gsnu200800


"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


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Prompt user to select a shape

If you mean by click the shape. We will use two macros:

Sub pic_click()
MsgBox (Application.Caller)
'do something else
End Sub

Sub tell_user()
MsgBox ("please click on a shape")
End Sub

Both macros go in standard modules. Right-click all the shapes and Assign
Macro...
All shapes are to be assigned the pic_click macro

1. first run tell_user. The user will first click the ok button and then
click on a shape
2. this causes the pic_click macro to run. Application.Caller tells the
user (and your VBA) exactly which shape was clicked.


Putting macros on Shapes is just as effective as putting them on Buttons and
a lot more fun!



--
Gary''s Student - gsnu2007k


"MM User" wrote:

Apologies but I need the user to actually select the shape not enter the
name - is this possible?

thanks


"Gary''s Student" wrote in message
...
Sub shapepicker()
x = Application.InputBox(prompt:="enter the shape name: ", Type:=2)
ActiveSheet.Shapes(x).Select
End Sub

The user would enter something like Oval 1
--
Gary''s Student - gsnu200800


"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



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Prompt user to select a shape

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


  #6   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 08:12 AM.

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

About Us

"It's about Microsoft Excel"