?
Solved

VBA to check if charttype is 3D

Posted on 2011-09-05
4
Medium Priority
?
410 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 81

Accepted Solution

by:
byundt earned 2000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

777 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