Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default XL2007 Bug: ControlFormat in "For each"

Code using "ControlFormat" that worked in the previous version of Excel does
not work in Excel 2007.
In Excel 2007, start with a new worksheet, add an autoshape, such as an
oval, and select the shape. Run the following code (after removing the 's
with Ctrl H).

Sub Play6()
Dim varShape As Variant
Dim shpS As Shape
Debug.Print Selection.ShapeRange(1).ControlFormat.LockedText
For Each varShape In Selection.ShapeRange
Debug.Print varShape.Name
Debug.Print varShape.ControlFormat.LockedText
Next varShape
End Sub


The first and second print statements do fine. They print
True
Oval 1
The third produces an error:
"Object doesn't support this property or method."
This effectively makes ControlFormat unusable, because which shapes the user
selects can't be known in advance. (Anyone see a workaround?)
I also note that the variable varShape had to be declared as a variant. In
the previous version of Excel, it could be declared as a shape.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default XL2007 Bug: ControlFormat in "For each"

Here's a workaround: just change the For each... Next to For... Next. The
following works:

Sub Play7()
Dim shpS As Shape
Dim N As Integer
For N = 1 To Selection.ShapeRange.Count
Set shpS = Selection.ShapeRange(N)
With shpS
Debug.Print shpS.Name
Debug.Print shpS.ControlFormat.LockedText
End With
Next N
End Sub


This solution to the problem seems general, so this bug doesn't seem so
critical as I originally thought.

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
Add csv to Open "All Excel Files" (XL2007) Jim Excel Discussion (Misc queries) 3 September 2nd 08 06:08 PM
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
change "true" and "false" to "availble" and "out of stock" inthestands Excel Worksheet Functions 2 July 19th 07 07:05 PM
HELP on "left","right","find","len","substitute" functions serene83 Excel Discussion (Misc queries) 5 June 27th 06 02:23 AM
Count occurences of "1"/"0" (or"TRUE"/"FALSE") in a row w. conditions in the next BCB New Users to Excel 7 May 13th 06 10:02 PM


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