Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB How-To
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 26th, 2008, 12:21 PM
Registered User
 
Join Date: Feb 2008
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default moving graph using macro

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?



Reply With Quote
  #2 (permalink)  
Old April 29th, 2008, 07:40 AM
Friend of Wrox
Points: 687, Level: 9
Points: 687, Level: 9 Points: 687, Level: 9 Points: 687, Level: 9
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2004
Location: Chennai, Tamilnadu, India.
Posts: 221
Thanks: 0
Thanked 0 Times in 0 Posts
Default

or you can try like this...

Dim i As Integer
i = Charts.Count
Charts(i - 1).Select
With Selection
    .Width
    .Height
    .Left
    .Top
End With

hope this helps.

With Regards,
Raghavendra Mudugal
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
calling to xlam macro from macro inside xlsb SteveB Excel VBA 0 June 30th, 2008 06:43 PM
graph pab006 Classic ASP Basics 5 July 26th, 2004 10:06 AM
line graph pab006 Classic ASP Basics 4 July 22nd, 2004 09:09 AM
graph pab006 Classic ASP Basics 1 April 30th, 2004 10:08 PM
Graph Customization hosefo81 PHP How-To 3 November 10th, 2003 03:07 PM



All times are GMT -4. The time now is 09:33 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.