Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 273
Default Using Application.Inputbox with shapes

I would like to allow prompt a user to select a shape (for example a
rectangle) Once they have done that I want to grab that shape's name and
position.

Currently what I have, prompts them to select the shape when they hit ok, it
exits from the macro. They then have to re-enter in to the macro to proceed.

I've looked into using Application.InputBox but it doesn't seem to allow the
user to select a shape on the sheet. Any help would be greatly appreciated.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Using Application.Inputbox with shapes

I don't see any way to do this using application.inputbox.

I use xl2003.

There's an icon I can add to my favorite toolbar that allows me to select
multiple objects.

Tools|Customize|Commands tab|Drawing category
Look for "Select multiple objects"
and drag it to your favorite toolbar.

When you click on that icon, you'll get a list of objects on that activesheet
that can be selected.

You can actually invoke that same icon in code.

If you want to try this:

Option Explicit
Sub testme()
Dim iCtr As Long
Dim mySelection As Object
Dim myCtrl As CommandBarControl
Dim TempCMDBar As CommandBar
Dim myCtrlId As Long

myCtrlId = 3990
'I'm not sure if it stays the same number in all versions and languages.

Set TempCMDBar = Nothing

'look for "select multiple objects icon
Set myCtrl = Application.CommandBars.FindControl(ID:=myCtrlId)

If myCtrl Is Nothing Then
'it wasn't found, so create a temporary toolbar to hold it
Set TempCMDBar = Application.CommandBars.Add(temporary:=True)
Set myCtrl _
= TempCMDBar.Controls.Add(Type:=msoControlButton, ID:=myCtrlId)
End If

myCtrl.Execute
Set mySelection = Selection

'clean up
If TempCMDBar Is Nothing Then
'nothing to do
Else
TempCMDBar.Delete
End If

If TypeName(mySelection) = "Range" Then
'didn't select any objects
MsgBox "a range was selected"
Else
With mySelection.ShapeRange
MsgBox .Count 'just to show you how many objects were selected
For iCtr = 1 To .Count
MsgBox .Item(iCtr).Name
Next iCtr
End With
End If

End Sub





Chad wrote:

I would like to allow prompt a user to select a shape (for example a
rectangle) Once they have done that I want to grab that shape's name and
position.

Currently what I have, prompts them to select the shape when they hit ok, it
exits from the macro. They then have to re-enter in to the macro to proceed.

I've looked into using Application.InputBox but it doesn't seem to allow the
user to select a shape on the sheet. Any help would be greatly appreciated.


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Using Application.Inputbox with shapes

Your observations are correct.

Work arounds would involve using two macros with the second triggered by the
selection. Use the onaction property of the rectangles to execute the second
macro.

an alternative may be to use application.Ontime to start the second after a
reasonable time to do the selection (although this is obviously not a good
way).

--
Regards,
Tom Ogilvy


"Chad" wrote:

I would like to allow prompt a user to select a shape (for example a
rectangle) Once they have done that I want to grab that shape's name and
position.

Currently what I have, prompts them to select the shape when they hit ok, it
exits from the macro. They then have to re-enter in to the macro to proceed.

I've looked into using Application.InputBox but it doesn't seem to allow the
user to select a shape on the sheet. Any help would be greatly appreciated.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 273
Default Using Application.Inputbox with shapes

Tom and Dave,

Thanks so much for the help. I think I can make one of these options work.
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Using Application.Inputbox with shapes

That is certainly an innovative solution!

--
Regards,
Tom Ogilvy


"Dave Peterson" wrote:

I don't see any way to do this using application.inputbox.

I use xl2003.

There's an icon I can add to my favorite toolbar that allows me to select
multiple objects.

Tools|Customize|Commands tab|Drawing category
Look for "Select multiple objects"
and drag it to your favorite toolbar.

When you click on that icon, you'll get a list of objects on that activesheet
that can be selected.

You can actually invoke that same icon in code.

If you want to try this:

Option Explicit
Sub testme()
Dim iCtr As Long
Dim mySelection As Object
Dim myCtrl As CommandBarControl
Dim TempCMDBar As CommandBar
Dim myCtrlId As Long

myCtrlId = 3990
'I'm not sure if it stays the same number in all versions and languages.

Set TempCMDBar = Nothing

'look for "select multiple objects icon
Set myCtrl = Application.CommandBars.FindControl(ID:=myCtrlId)

If myCtrl Is Nothing Then
'it wasn't found, so create a temporary toolbar to hold it
Set TempCMDBar = Application.CommandBars.Add(temporary:=True)
Set myCtrl _
= TempCMDBar.Controls.Add(Type:=msoControlButton, ID:=myCtrlId)
End If

myCtrl.Execute
Set mySelection = Selection

'clean up
If TempCMDBar Is Nothing Then
'nothing to do
Else
TempCMDBar.Delete
End If

If TypeName(mySelection) = "Range" Then
'didn't select any objects
MsgBox "a range was selected"
Else
With mySelection.ShapeRange
MsgBox .Count 'just to show you how many objects were selected
For iCtr = 1 To .Count
MsgBox .Item(iCtr).Name
Next iCtr
End With
End If

End Sub





Chad wrote:

I would like to allow prompt a user to select a shape (for example a
rectangle) Once they have done that I want to grab that shape's name and
position.

Currently what I have, prompts them to select the shape when they hit ok, it
exits from the macro. They then have to re-enter in to the macro to proceed.

I've looked into using Application.InputBox but it doesn't seem to allow the
user to select a shape on the sheet. Any help would be greatly appreciated.


--

Dave Peterson



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Using Application.Inputbox with shapes

And it just may work <vbg.

Tom Ogilvy wrote:

That is certainly an innovative solution!

--
Regards,
Tom Ogilvy

"Dave Peterson" wrote:

I don't see any way to do this using application.inputbox.

I use xl2003.

There's an icon I can add to my favorite toolbar that allows me to select
multiple objects.

Tools|Customize|Commands tab|Drawing category
Look for "Select multiple objects"
and drag it to your favorite toolbar.

When you click on that icon, you'll get a list of objects on that activesheet
that can be selected.

You can actually invoke that same icon in code.

If you want to try this:

Option Explicit
Sub testme()
Dim iCtr As Long
Dim mySelection As Object
Dim myCtrl As CommandBarControl
Dim TempCMDBar As CommandBar
Dim myCtrlId As Long

myCtrlId = 3990
'I'm not sure if it stays the same number in all versions and languages.

Set TempCMDBar = Nothing

'look for "select multiple objects icon
Set myCtrl = Application.CommandBars.FindControl(ID:=myCtrlId)

If myCtrl Is Nothing Then
'it wasn't found, so create a temporary toolbar to hold it
Set TempCMDBar = Application.CommandBars.Add(temporary:=True)
Set myCtrl _
= TempCMDBar.Controls.Add(Type:=msoControlButton, ID:=myCtrlId)
End If

myCtrl.Execute
Set mySelection = Selection

'clean up
If TempCMDBar Is Nothing Then
'nothing to do
Else
TempCMDBar.Delete
End If

If TypeName(mySelection) = "Range" Then
'didn't select any objects
MsgBox "a range was selected"
Else
With mySelection.ShapeRange
MsgBox .Count 'just to show you how many objects were selected
For iCtr = 1 To .Count
MsgBox .Item(iCtr).Name
Next iCtr
End With
End If

End Sub





Chad wrote:

I would like to allow prompt a user to select a shape (for example a
rectangle) Once they have done that I want to grab that shape's name and
position.

Currently what I have, prompts them to select the shape when they hit ok, it
exits from the macro. They then have to re-enter in to the macro to proceed.

I've looked into using Application.InputBox but it doesn't seem to allow the
user to select a shape on the sheet. Any help would be greatly appreciated.


--

Dave Peterson


--

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
Application.InputBox Steven Excel Programming 2 December 23rd 06 11:56 PM
application.inputbox Christmas May[_2_] Excel Programming 5 November 22nd 06 04:11 PM
Inputbox and Application.InputBox Maria[_7_] Excel Programming 1 September 20th 04 11:36 AM
inputbox and application.run macro1 Michael Joe Excel Programming 3 August 13th 04 09:34 PM
application.inputbox Murat Excel Programming 4 February 24th 04 11:38 AM


All times are GMT +1. The time now is 03:35 AM.

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"