Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 47
Default Selecting Shapes

Hi,
I'd like to create write a function behind a button that selects all the
jpg images embedded on the worksheet surface. The command I found for this
is activesheet.Shapes.Range(Array(n1, n2, ...)).Select. At least this is the
command which provides for one shot selection. I have not been successful
selecting one image at a time without the previous selection "de-selecting".

Since there are other buttons and labels on this same worksheet that I don't
want selected, I want to start the Array beyond these indexes. Assumption:
the jpg's will always be a contiguous set of indicies once the first shape
index (type = 13) is found in the shaperange array. I can find the starting
index easy enough looping through the shapes array looking at the type.

Since the total number of shapes can vary, I can't hardcode in the Array
function indicies and I don't know how to place a variable into the arglist
of the Array function rather than literals. Any advice?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 128
Default Selecting Shapes

On May 21, 11:54 am, RLang wrote:
Hi,
I'd like to create write a function behind a button that selects all the
jpg images embedded on the worksheet surface. The command I found for this
is activesheet.Shapes.Range(Array(n1, n2, ...)).Select. At least this is the
command which provides for one shot selection. I have not been successful
selecting one image at a time without the previous selection "de-selecting".

Since there are other buttons and labels on this same worksheet that I don't
want selected, I want to start the Array beyond these indexes. Assumption:
the jpg's will always be a contiguous set of indicies once the first shape
index (type = 13) is found in the shaperange array. I can find the starting
index easy enough looping through the shapes array looking at the type.

Since the total number of shapes can vary, I can't hardcode in the Array
function indicies and I don't know how to place a variable into the arglist
of the Array function rather than literals. Any advice?


Hello RLang,

Here is a macro that will select all Pictures on the active sheet. It
does so by creating a 1 based Variant array, which is what the Array
function does. The difference here is the Variant array is dynamic.
Add a standard module to your project and copy this code to it.

Macro Code
'---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Option Base 1

Sub SelectAllPictures()

Dim N As Long
Dim ShpArray() As Variant

For Each Shp In ActiveSheet
If Shp.Type = msoPicture Then
N = N + 1
ReDim Preserve ShpArray(N)
ShpArray(N) = Shp.Name
End If
Next Sht

Shapes(ShpArray).Select

End Sub
'---------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Sincerely,
Leith Ross
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 47
Default Selecting Shapes

Hi Leith,
thanks for responding. I'm getting a "Type Mismatch" error on the final
select statement. Everything else works up to that point. Here's my code:

Option Base 1
Public Sub cmdSelectAll_Click()

Dim ImgArray() As Variant, j As Long, Shp

j = 0
For Each Shp In ActiveSheet.Shapes
If Shp.type = 13 Then
j = j + 1
ReDim Preserve ImgArray(j)
ImgArray(j) = Shp.Name
End If
Next Shp
Shapes(ImgArray).Select

End Sub


"Leith Ross" wrote:

On May 21, 11:54 am, RLang wrote:
Hi,
I'd like to create write a function behind a button that selects all the
jpg images embedded on the worksheet surface. The command I found for this
is activesheet.Shapes.Range(Array(n1, n2, ...)).Select. At least this is the
command which provides for one shot selection. I have not been successful
selecting one image at a time without the previous selection "de-selecting".

Since there are other buttons and labels on this same worksheet that I don't
want selected, I want to start the Array beyond these indexes. Assumption:
the jpg's will always be a contiguous set of indicies once the first shape
index (type = 13) is found in the shaperange array. I can find the starting
index easy enough looping through the shapes array looking at the type.

Since the total number of shapes can vary, I can't hardcode in the Array
function indicies and I don't know how to place a variable into the arglist
of the Array function rather than literals. Any advice?


Hello RLang,

Here is a macro that will select all Pictures on the active sheet. It
does so by creating a 1 based Variant array, which is what the Array
function does. The difference here is the Variant array is dynamic.
Add a standard module to your project and copy this code to it.

Macro Code
'---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Option Base 1

Sub SelectAllPictures()

Dim N As Long
Dim ShpArray() As Variant

For Each Shp In ActiveSheet
If Shp.Type = msoPicture Then
N = N + 1
ReDim Preserve ShpArray(N)
ShpArray(N) = Shp.Name
End If
Next Sht

Shapes(ShpArray).Select

End Sub
'---------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Sincerely,
Leith Ross

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 128
Default Selecting Shapes

On May 21, 12:54 pm, RLang wrote:
Hi Leith,
thanks for responding. I'm getting a "Type Mismatch" error on the final
select statement. Everything else works up to that point. Here's my code:

Option Base 1
Public Sub cmdSelectAll_Click()

Dim ImgArray() As Variant, j As Long, Shp

j = 0
For Each Shp In ActiveSheet.Shapes
If Shp.type = 13 Then
j = j + 1
ReDim Preserve ImgArray(j)
ImgArray(j) = Shp.Name
End If
Next Shp
Shapes(ImgArray).Select

End Sub

"Leith Ross" wrote:
On May 21, 11:54 am, RLang wrote:
Hi,
I'd like to create write a function behind a button that selects all the
jpg images embedded on the worksheet surface. The command I found for this
is activesheet.Shapes.Range(Array(n1, n2, ...)).Select. At least this is the
command which provides for one shot selection. I have not been successful
selecting one image at a time without the previous selection "de-selecting".


Since there are other buttons and labels on this same worksheet that I don't
want selected, I want to start the Array beyond these indexes. Assumption:
the jpg's will always be a contiguous set of indicies once the first shape
index (type = 13) is found in the shaperange array. I can find the starting
index easy enough looping through the shapes array looking at the type.


Since the total number of shapes can vary, I can't hardcode in the Array
function indicies and I don't know how to place a variable into the arglist
of the Array function rather than literals. Any advice?


Hello RLang,


Here is a macro that will select all Pictures on the active sheet. It
does so by creating a 1 based Variant array, which is what the Array
function does. The difference here is the Variant array is dynamic.
Add a standard module to your project and copy this code to it.


Macro Code
'---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Option Base 1


Sub SelectAllPictures()


Dim N As Long
Dim ShpArray() As Variant


For Each Shp In ActiveSheet
If Shp.Type = msoPicture Then
N = N + 1
ReDim Preserve ShpArray(N)
ShpArray(N) = Shp.Name
End If
Next Sht


Shapes(ShpArray).Select


End Sub
'---------------------------------------------------------------------------------------------------------------------------------------------------------------------------


Sincerely,
Leith Ross


Hello RLang,

Sorry about that. The line should read...

ActiveSheet.Shapes(ShpArray).Select

Sincerely,
Leith Ross
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Selecting Shapes

Based on Leith's response:

Option Explicit
Sub SelectAllPictures2()

Dim N As Long
Dim ShpArray() As Variant
Dim Shp As Shape

N = 0
For Each Shp In ActiveSheet.Shapes
If Shp.Type = msoPicture Then
N = N + 1
ReDim Preserve ShpArray(1 To N)
ShpArray(N) = Shp.Name
End If
Next Shp

If N = 0 Then
MsgBox "No pics"
Else
ActiveSheet.Shapes.Range(ShpArray).Select
End If

End Sub



RLang wrote:

Hi,
I'd like to create write a function behind a button that selects all the
jpg images embedded on the worksheet surface. The command I found for this
is activesheet.Shapes.Range(Array(n1, n2, ...)).Select. At least this is the
command which provides for one shot selection. I have not been successful
selecting one image at a time without the previous selection "de-selecting".

Since there are other buttons and labels on this same worksheet that I don't
want selected, I want to start the Array beyond these indexes. Assumption:
the jpg's will always be a contiguous set of indicies once the first shape
index (type = 13) is found in the shaperange array. I can find the starting
index easy enough looping through the shapes array looking at the type.

Since the total number of shapes can vary, I can't hardcode in the Array
function indicies and I don't know how to place a variable into the arglist
of the Array function rather than literals. Any advice?


--

Dave Peterson


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 47
Default Selecting Shapes

Thanks very much Leith, I'm now squared away based on your advice.

"Leith Ross" wrote:

On May 21, 12:54 pm, RLang wrote:
Hi Leith,
thanks for responding. I'm getting a "Type Mismatch" error on the final
select statement. Everything else works up to that point. Here's my code:

Option Base 1
Public Sub cmdSelectAll_Click()

Dim ImgArray() As Variant, j As Long, Shp

j = 0
For Each Shp In ActiveSheet.Shapes
If Shp.type = 13 Then
j = j + 1
ReDim Preserve ImgArray(j)
ImgArray(j) = Shp.Name
End If
Next Shp
Shapes(ImgArray).Select

End Sub

"Leith Ross" wrote:
On May 21, 11:54 am, RLang wrote:
Hi,
I'd like to create write a function behind a button that selects all the
jpg images embedded on the worksheet surface. The command I found for this
is activesheet.Shapes.Range(Array(n1, n2, ...)).Select. At least this is the
command which provides for one shot selection. I have not been successful
selecting one image at a time without the previous selection "de-selecting".


Since there are other buttons and labels on this same worksheet that I don't
want selected, I want to start the Array beyond these indexes. Assumption:
the jpg's will always be a contiguous set of indicies once the first shape
index (type = 13) is found in the shaperange array. I can find the starting
index easy enough looping through the shapes array looking at the type.


Since the total number of shapes can vary, I can't hardcode in the Array
function indicies and I don't know how to place a variable into the arglist
of the Array function rather than literals. Any advice?


Hello RLang,


Here is a macro that will select all Pictures on the active sheet. It
does so by creating a 1 based Variant array, which is what the Array
function does. The difference here is the Variant array is dynamic.
Add a standard module to your project and copy this code to it.


Macro Code
'---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Option Base 1


Sub SelectAllPictures()


Dim N As Long
Dim ShpArray() As Variant


For Each Shp In ActiveSheet
If Shp.Type = msoPicture Then
N = N + 1
ReDim Preserve ShpArray(N)
ShpArray(N) = Shp.Name
End If
Next Sht


Shapes(ShpArray).Select


End Sub
'---------------------------------------------------------------------------------------------------------------------------------------------------------------------------


Sincerely,
Leith Ross


Hello RLang,

Sorry about that. The line should read...

ActiveSheet.Shapes(ShpArray).Select

Sincerely,
Leith Ross

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 47
Default Selecting Shapes

Thanks as well Dave!

"Dave Peterson" wrote:

Based on Leith's response:

Option Explicit
Sub SelectAllPictures2()

Dim N As Long
Dim ShpArray() As Variant
Dim Shp As Shape

N = 0
For Each Shp In ActiveSheet.Shapes
If Shp.Type = msoPicture Then
N = N + 1
ReDim Preserve ShpArray(1 To N)
ShpArray(N) = Shp.Name
End If
Next Shp

If N = 0 Then
MsgBox "No pics"
Else
ActiveSheet.Shapes.Range(ShpArray).Select
End If

End Sub



RLang wrote:

Hi,
I'd like to create write a function behind a button that selects all the
jpg images embedded on the worksheet surface. The command I found for this
is activesheet.Shapes.Range(Array(n1, n2, ...)).Select. At least this is the
command which provides for one shot selection. I have not been successful
selecting one image at a time without the previous selection "de-selecting".

Since there are other buttons and labels on this same worksheet that I don't
want selected, I want to start the Array beyond these indexes. Assumption:
the jpg's will always be a contiguous set of indicies once the first shape
index (type = 13) is found in the shaperange array. I can find the starting
index easy enough looping through the shapes array looking at the type.

Since the total number of shapes can vary, I can't hardcode in the Array
function indicies and I don't know how to place a variable into the arglist
of the Array function rather than literals. Any advice?


--

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
Selecting Multiple Shapes and Lines Nash Excel Discussion (Misc queries) 1 February 19th 10 11:42 PM
Selecting shapes with unknown names JBCI Excel Discussion (Misc queries) 0 March 10th 08 05:45 PM
Selecting shapes Daniel Bonallack Excel Discussion (Misc queries) 1 June 5th 07 04:57 PM
Saving the spreadsheet only with no code? Selecting shapes too. groundhog1 Excel Programming 4 February 21st 06 05:14 AM
Selecting drawing objects or shapes in a macro John DeFiore Excel Programming 3 October 13th 03 02:26 PM


All times are GMT +1. The time now is 06:54 PM.

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"