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

hi,

i often use application.inputbox like

Set mycell1 = Application.InputBox(prompt:="", Type:=8)

in order to get a range,

but it failed to let me select a shape, i mean a shape object, that is a
part of drawing i cilpped and paseted into a sheet,

how to do this,

thanks a lot




  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 43
Default how to select a shape

of course ,i mean how to select a shape in vba,

"EXCEL$B!!(BNEWS" wrote in message
...
hi,

i often use application.inputbox like

Set mycell1 = Application.InputBox(prompt:="", Type:=8)

in order to get a range,

but it failed to let me select a shape, i mean a shape object, that is a
part of drawing i cilpped and paseted into a sheet,

how to do this,

thanks a lot





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default how to select a shape

I don't think you can select a shape using the mouse from VBA
code. Application.InputBox certainly won't do it. I tried to do
it with a modeless userform, but apparently Excel prohibits
selecting anything in the drawing layer.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com

"EXCEL$B!!(BNEWS" wrote in message
...
hi,

i often use application.inputbox like

Set mycell1 = Application.InputBox(prompt:="", Type:=8)

in order to get a range,

but it failed to let me select a shape, i mean a shape object,
that is a
part of drawing i cilpped and paseted into a sheet,

how to do this,

thanks a lot






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 43
Default how to select a shape

thanks for your answer

but i mean i just want to select a shape which is within a excel sheet,
instead of selecting a drawing scope in a cad area,
i dont know the meaning of "selecting anything in the drawing lay"

i think there should be a method to let me do it, in vba,

what does modeless userform mean, would you please give me any hint further,

thanks a lot




"Chip Pearson" wrote in message
...
I don't think you can select a shape using the mouse from VBA
code. Application.InputBox certainly won't do it. I tried to do
it with a modeless userform, but apparently Excel prohibits
selecting anything in the drawing layer.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com

"EXCEL$B!!(BNEWS" wrote in message
...
hi,

i often use application.inputbox like

Set mycell1 = Application.InputBox(prompt:="", Type:=8)

in order to get a range,

but it failed to let me select a shape, i mean a shape object,
that is a
part of drawing i cilpped and paseted into a sheet,

how to do this,

thanks a lot







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

Pictures/shapes/buttons/controls don't live on the worksheet itself. They live
on a layer that floats over that worksheet (kind of like the different layers in
AutoCad).

That layer that floats over the worksheet is the excel's drawing layer.

A modeless userform is a userform that doesn't take control of the application.

If you click on File|SaveAs, you'll notice that you can't do anything else while
that dialog is showing.

If you click on Edit|Find (in xl2002+), you'll see that you can click on other
cells and continue to work while that dialog is still showing.



EXCEL$B!!(BNEWS wrote:

thanks for your answer

but i mean i just want to select a shape which is within a excel sheet,
instead of selecting a drawing scope in a cad area,
i dont know the meaning of "selecting anything in the drawing lay"

i think there should be a method to let me do it, in vba,

what does modeless userform mean, would you please give me any hint further,

thanks a lot

"Chip Pearson" wrote in message
...
I don't think you can select a shape using the mouse from VBA
code. Application.InputBox certainly won't do it. I tried to do
it with a modeless userform, but apparently Excel prohibits
selecting anything in the drawing layer.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com

"EXCEL$B!!(BNEWS" wrote in message
...
hi,

i often use application.inputbox like

Set mycell1 = Application.InputBox(prompt:="", Type:=8)

in order to get a range,

but it failed to let me select a shape, i mean a shape object,
that is a
part of drawing i cilpped and paseted into a sheet,

how to do this,

thanks a lot







--

Dave Peterson


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

There's a button that you can add to your favorite toolbar that pops up a dialog
that allows you to select a shape based on the names of the shapes on that
worksheet.

Tools|Customize|Commands tab|Drawing toolbar
Look for Select Multiple Objects in the commands list.

Maybe you could invoke that dialog in your code:

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

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)

'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.

EXCEL$B!!(BNEWS wrote:

hi,

i often use application.inputbox like

Set mycell1 = Application.InputBox(prompt:="", Type:=8)

in order to get a range,

but it failed to let me select a shape, i mean a shape object, that is a
part of drawing i cilpped and paseted into a sheet,

how to do this,

thanks a lot


--

Dave Peterson
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default how to select a shape

thanks a lot and thanks for your code
maybe as you said , to let the users to select the object before the code
starts is the best way ,

thanks


"Dave Peterson" wrote in message
...
There's a button that you can add to your favorite toolbar that pops up a

dialog
that allows you to select a shape based on the names of the shapes on that
worksheet.

Tools|Customize|Commands tab|Drawing toolbar
Look for Select Multiple Objects in the commands list.

Maybe you could invoke that dialog in your code:

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

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)

'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.

EXCEL$B!!(BNEWS wrote:

hi,

i often use application.inputbox like

Set mycell1 = Application.InputBox(prompt:="", Type:=8)

in order to get a range,

but it failed to let me select a shape, i mean a shape object, that is a
part of drawing i cilpped and paseted into a sheet,

how to do this,

thanks a lot


--

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
my curser changed from arrow shape to a cross shape???? bj New Users to Excel 1 February 5th 07 02:47 PM
Possible to select a range of cells from a Shape Object Gummy Excel Programming 1 May 11th 06 12:06 AM
Select shape leading to Out of memory Laguna Excel Programming 4 July 6th 05 04:47 AM
Run-Time Error: You must select a shape Lee Excel Worksheet Functions 1 January 25th 05 05:31 PM
Select Multiple Shape Objects Alan Excel Programming 0 November 24th 04 06:25 AM


All times are GMT +1. The time now is 09:11 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"