Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Problem with Shape Names containing punctuation

My routine to create an object of multiple shapes fails if any shape name
includes punctuation, eg

"My.Rectangle 1"

Sub TestMultiObject()
Dim cnt As Long, i as Long
Dim ob As Object

With ActiveSheet.Shapes
cnt = .Count
ReDim vArr(1 To cnt)
For i = 1 To cnt 'don't want to use "For Each"
vArr(i) = .Item(i).Name
Next
End With

'fails if any shape Name includes a dot
Set ob = ActiveSheet.DrawingObjects(vArr)

'always works
'Set ob = ActiveSheet.Shapes.Range(vArr)

MsgBox ob.Count
End Sub

I don't know why I have this problem with punctuation in shape names. First
question - does anyone else have same problem, or rather not replicate this
problem.

I have a convoluted reason for not wanting to use the line that "always
works".

Assuming this affects all users/versions, does anyone know how to create a
multiple object at the "DrawingObjects" level that caters for the
possibility of a name including punctuation.

TIA,
Peter T


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Problem with Shape Names containing punctuation

I have used shapes with names containing punctuation, but never access them
by name in an array. Try accessing by index instead.
Try this:

With ActiveSheet.Shapes
cnt = .Count
ReDim vArr(1 To cnt)
For i = 1 To cnt 'don't want to use "For Each"
'vArr(i) = .Item(i).Name
vArr(i) = i ' Changes to use index instead of name.
Next
End With

'fails if any shape Name includes a dot
Set ob = ActiveSheet.DrawingObjects(vArr)

Carlos Lozano
CAX IT Services
www.caxonline.net

"Peter T" wrote:

My routine to create an object of multiple shapes fails if any shape name
includes punctuation, eg

"My.Rectangle 1"

Sub TestMultiObject()
Dim cnt As Long, i as Long
Dim ob As Object

With ActiveSheet.Shapes
cnt = .Count
ReDim vArr(1 To cnt)
For i = 1 To cnt 'don't want to use "For Each"
vArr(i) = .Item(i).Name
Next
End With

'fails if any shape Name includes a dot
Set ob = ActiveSheet.DrawingObjects(vArr)

'always works
'Set ob = ActiveSheet.Shapes.Range(vArr)

MsgBox ob.Count
End Sub

I don't know why I have this problem with punctuation in shape names. First
question - does anyone else have same problem, or rather not replicate this
problem.

I have a convoluted reason for not wanting to use the line that "always
works".

Assuming this affects all users/versions, does anyone know how to create a
multiple object at the "DrawingObjects" level that caters for the
possibility of a name including punctuation.

TIA,
Peter T



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Problem with Shape Names containing punctuation

Hi Carlos,

That's great, and so simple !

Thanks,
Peter T

"Carlos Lozano" wrote in message
...
I have used shapes with names containing punctuation, but never access

them
by name in an array. Try accessing by index instead.
Try this:

With ActiveSheet.Shapes
cnt = .Count
ReDim vArr(1 To cnt)
For i = 1 To cnt 'don't want to use "For Each"
'vArr(i) = .Item(i).Name
vArr(i) = i ' Changes to use index instead of name.
Next
End With

'fails if any shape Name includes a dot
Set ob = ActiveSheet.DrawingObjects(vArr)

Carlos Lozano
CAX IT Services
www.caxonline.net

"Peter T" wrote:

My routine to create an object of multiple shapes fails if any shape

name
includes punctuation, eg

"My.Rectangle 1"

Sub TestMultiObject()
Dim cnt As Long, i as Long
Dim ob As Object

With ActiveSheet.Shapes
cnt = .Count
ReDim vArr(1 To cnt)
For i = 1 To cnt 'don't want to use "For Each"
vArr(i) = .Item(i).Name
Next
End With

'fails if any shape Name includes a dot
Set ob = ActiveSheet.DrawingObjects(vArr)

'always works
'Set ob = ActiveSheet.Shapes.Range(vArr)

MsgBox ob.Count
End Sub

I don't know why I have this problem with punctuation in shape names.

First
question - does anyone else have same problem, or rather not replicate

this
problem.

I have a convoluted reason for not wanting to use the line that "always
works".

Assuming this affects all users/versions, does anyone know how to create

a
multiple object at the "DrawingObjects" level that caters for the
possibility of a name including punctuation.

TIA,
Peter T





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
Ignore punctuation Purnima Excel Programming 2 March 10th 05 12:46 PM
Shape names Don Rouse Excel Programming 1 July 7th 04 12:21 AM
Deleting a shape and the cell contents the shape is in. Dave Peterson[_3_] Excel Programming 1 October 9th 03 03:36 PM
Deleting a shape and the cell contents the shape is in. Tom Ogilvy Excel Programming 0 October 9th 03 03:43 AM


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