Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 88
Default Test whether a chartobject is on a worksheet

Hello,

I need this test, because I have to adjust the legend and a text box
on my charts, which
always change their position (that's really annoying!).
In my workbook are also worksheets without embedded charts,
so I have to skip them.
Thanks.

Excel XP SP3
WIN XP SP1

Regards
Werner
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Test whether a chartobject is on a worksheet

Sub countum()
MsgBox (ActiveSheet.ChartObjects.Count)
End Sub

--
Gary''s Student - gsnu2007g


"Werner Rohrmoser" wrote:

Hello,

I need this test, because I have to adjust the legend and a text box
on my charts, which
always change their position (that's really annoying!).
In my workbook are also worksheets without embedded charts,
so I have to skip them.
Thanks.

Excel XP SP3
WIN XP SP1

Regards
Werner

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 88
Default Test whether a chartobject is on a worksheet

Hi Gary's Student,

thanks, simple and good.
BTW, do you know how the legend and textbox position change on the
chartobject can be avoided.
Because adjusting the shapes is fighting agianst the symptom but not
treating the root cause.

Werner

P.S.: Who is Garry?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Test whether a chartobject is on a worksheet

Gary was my Excel teacher.

I have never been able to stop objects from moving, but have always relied
on "remembering" where I want them, and then moving back there with Top or
Left.
--
Gary''s Student - gsnu2007g


"Werner Rohrmoser" wrote:

Hi Gary's Student,

thanks, simple and good.
BTW, do you know how the legend and textbox position change on the
chartobject can be avoided.
Because adjusting the shapes is fighting agianst the symptom but not
treating the root cause.

Werner

P.S.: Who is Garry?


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Test whether a chartobject is on a worksheet

Sub test()
Dim i As Long
Dim ws As Worksheet
Dim chtObj As ChartObject
Dim cht As Chart

For Each ws In ActiveWorkbook.Worksheets
For i = 1 To ws.ChartObjects.Count
Set cht = ws.ChartObjects(i).Chart
Debug.Print cht.Parent.Parent.Name, _
cht.Parent.Name, _
cht.HasLegend
Next
Next

End Sub

Although not typical embedded charts can also exist on a Chart sheet. If
that's a possibility -

Dim sht as Object
and change for each ws to
For each sht in Activeworkbook.Sheets

Regards,
Peter T

"Werner Rohrmoser" wrote in message
...
Hello,

I need this test, because I have to adjust the legend and a text box
on my charts, which
always change their position (that's really annoying!).
In my workbook are also worksheets without embedded charts,
so I have to skip them.
Thanks.

Excel XP SP3
WIN XP SP1

Regards
Werner





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 88
Default Test whether a chartobject is on a worksheet

Thanks Peter,

I'm going to use your structure to loop through my sheets.

Regards
Werner
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
How to find existing ChartObject in a worksheet? itdept Excel Programming 1 February 8th 07 03:09 PM
chart vs. chartobject Andreas Wendzel Excel Programming 3 February 7th 07 10:17 PM
Test worksheet name Petr Excel Programming 4 June 25th 04 01:57 PM
Test for Worksheet Paul Excel Programming 5 April 30th 04 10:29 PM
ChartObject index Claude Excel Programming 3 January 30th 04 09:33 PM


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