Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB How-To
|
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 6th, 2006, 09:24 AM
Registered User
 
Join Date: Mar 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default move chart with variable shape name

I have added a macro that will collect data and add a graph to my worksheet. Because users will be able to run this macro at any time and repeat the action indefinitely, the chart's name is always changing, e.g. "Chart 23", "Chart 24". After the chart is built I want to move the chart within the worksheet and resize it.

When I record the macro the code is:
ActiveSheet.Shapes("Chart 48").IncrementLeft -212.25
ActiveSheet.Shapes("Chart 48").ScaleWidth 1.52, msoFalse, msoScaleFromTopLeft

I have set a variable to capture the chart's name and it does so successfully (chartname1 = ActiveChart.Name). When I try to insert this into the code, however, it doesn't work.

ActiveSheet.Shapes(chartname1).IncrementLeft -212.25
ActiveSheet.Shapes(chartname1).ScaleWidth 1.52, msoFalse, msoScaleFromTopLeft

The debug says it can't find the object.

Any ideas on how to write this w/o a static chart name?

 
Old February 26th, 2008, 12:14 PM
Registered User
 
Join Date: Feb 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

I was just wondering if you ever found the solution to this problem? Or if anyone else out there knows the solution!!

Regards

MT






Similar Threads
Thread Thread Starter Forum Replies Last Post
Rotating shape in VBA (not center of shape) Piblon Excel VBA 3 April 13th, 2006 04:04 AM
Using Customized chart for Pivot Chart kliu9 Excel VBA 3 October 13th, 2004 09:37 AM
Shape My Command-Please btpoole VB Databases Basics 0 March 7th, 2004 12:33 AM
"No Fill" for Shape Objects msvedlow Excel VBA 2 September 5th, 2003 10:40 AM
Drill Down from Bar Chart to another chart snowbird Crystal Reports 0 July 11th, 2003 01:53 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.