Solved

VBA to check if charttype is 3D

Posted on 2011-09-05
4
364 Views
Last Modified: 2012-05-12
Hi Experts

I want to create a macro that checks if the chart a user has created is in 3D - I know there is a chartype property of chart, but this returns a number, does anyone have a list of numbers or is there a simpler way  -
currently I have

If InStr(UCase(mcht.ChartType), "3D") > 0 Then
       
            MsgBox "3D"
        End If
       
but as the charttpe is a number its not working, when selecting a charttype I can type in text
0
Comment
Question by:MrDavidThorn
  • 2
4 Comments
 
LVL 15

Expert Comment

by:CSLARSEN
ID: 36485093
Hi
You can check for the number in chart type.

Check a list of chartypes, e.g. http://it.toolbox.com/wiki/index.php/EXCEL_Chart_Type_Enumeration
Another more complete but also less elegant would be to insert all 3D numbers in an array to validate the selected charttype against.
However from my point of view you are not using a poor proxy for 3D identification.
Cheers
cslarsen
0
 
LVL 80

Accepted Solution

by:
byundt earned 500 total points
ID: 36485124
Here is a function that incorporates the numbers suggested by CSLARSEN. It returns TRUE if the ChartType is one of the 3D types. Install it in a regular module, or incorporate the logic in your sub.

Function IsChart3D(co As ChartObject) As Boolean
Select Case co.Chart.ChartType
Case -4102 To -4100, -4098, 54 To 56, 60 To 62, 78 To 79
    IsChart3D = True
End Select
End Function

Open in new window

0
 
LVL 15

Expert Comment

by:CSLARSEN
ID: 36485406
Nice one byundt
learned the compact array/case part
thx carsten
0
 

Author Closing Comment

by:MrDavidThorn
ID: 36485466
thanks guys
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

What is a Form List Box? (skip if you know this) The forms List Box is the alternative to the ActiveX list box. If you are using excel 2007, you first make sure you have a developer tab (click the Orb)->"Excel Options"->Popular->"Show Developer tab…
A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now