Changing line transparency of a series without affecting marker transparency in Excel VBA - vba

I am writing a macro in VBA for excel in which I would like to change the transparency of the lines connecting markers in a series but leave the transparency of the markers in the series the same.
To specify: the chart is a scatter plot. I would like the markers for a series to be opaque/zero transparency and for the lines in the series to be 75% transparent.
I have adjsuted the transparency of the lines by using
myseries.format.line.transparency = 0.75
but this changes the marker transparency as well.
does anyone know of a way I can change the transparency of the two separately? I imagine there is a member/property to do what I want, but I cannot find it.
thanks in advance for any help!

This answer isn't going to make you very happy.
I've looked into this before and the information i've gotten is that this simply isn't a parameter that you can specify through VBA. It looks like you can access marker style, size, background color and foreground color, and that's about it.
Maybe MS didn't think anyone would ever want to mess with that.
One thing you could try is applying a custom chart format, but if you have variable numbers and/or orders of series then that may not work.
mychart.ApplyChartTemplate ("filepath\filename.crtx")
Something like that, where mychart is already set equal to the chart you want to format.
Again, maybe not of any use to you, best i could think of.

You guys didn't dig hard enough.
SeriesCollection(i).Format.Line.Transparency
will work if the SeriesObject is in a certain state. The original 'automatic' line style state prevents this vba from doing anything at first, but if you simply precede it by setting certain other properties on the line format first, then the transparency will take. The following worked for me:
For Each obj In myChart.SeriesCollection
obj.Format.Line.DashStyle = 1
obj.Format.Line.Transparency = 0.65
Next obj
DashStyle = 1 sets the line style to 'Solid' (as opposed to dashed, dotted, etc.) and has the side effect of freeing up the series format to have the transparency set. I don't know for sure why it works, but it does.

Sorry, my mistake. I read the question slightly wrong.
I find that if I start the line with no markers, then turning transparency separately doesn't turn the markers on and off.

Try this:
activechart.SeriesCollection(1).format.fill.transparency=0.5

Related

Coyping grouped images as picture and crop it in ppt via vba

I have a problem to get a certain amount of shapes in ppt to a certain format. I generate them via nprinting and they are already grouped properly. The problem is that I can´t crop them once their grouped. If they are not grouped I can address each of them individually and crop them the way I want. I need them in picture(u) format in order to be able to crop them. My approach was to cut them and insert them again but as picture. Unfortunately I wasn´t able to cut and paste them via vba with the code below. Does anyone have an idea how to solve this?
Dim myDocument As Object
Set SlidePPT = objPPT.Presentations(FilePPT).Slides(7)
SlidePPT.Select
myDocument.Slides(7).Shapes.SelectAll.Group
Selection.Cut
myDocument.Slides(7).Pictures.Paste
myDocument.Slides(7).Shapes(1).PictureFormat.CropBottom = 200
The alternativ I had in mind was to crop it first and Group it then, but this seems not to work either.
edit: Okay, it seems that the problem with my alternative approach is, that my code just selects all of the shapes but does not group them. Any ideas on that?
Solved it. i just needed to add the range.
myDocument.Slides(7).Shapes.Range.Group

Referencing text from a 1D array for use in a line of code (vb)

I'm working on a small project, and one of the components utilizes an animated dice. I've got the mechanics of the dice down, however, I wish to make the dice colour change each time it rolls.
As of now, I have to manually set the colour
(e.g. pnl1.Backcolor = system.Drawing.color.Red).
I've already set up an array with the various different colours and intend to reference them randomly using the random number function, but my question is how can I refer to an item in the array in such a way that that makes the above mentioned pnl1.Backcolor match said colour?
I'm well aware I can't just use system.Drawing.color.Colours(1), so how might I go about this/what are some possible alternate options to an array?
Any and all help is massively appreciated and I do apologise if the way I've formatted this question is not in line with that which the website demands (I'm relatively new).
Thanks,
~ John
I'm not sure whether you have a different panel for each side of the die or just one with a picture change, nevertheless, below is an example of something you could do. Change as needed (I'm assuming just one panel with color change - pnl1).
Dim PanColor() As Color = {Color.White, Color.Red, Color.Green, Color.Blue, Color.Purple, Color.Yellow}
pnl1.BackColor = PanColor(put_random_number_here_0_to_5)

Can VBA detect line-wrapping in an Excel chart legend?

Context
Writing to code to format a chart (all of which should be done by Microsoft, but that’s separate).
Am now positioning the legend. Taking a 9×9 block of possible positions, and counting the data points underneath each. As a fragment of the code: (ax.MaximumScale - ax.MinimumScale) * co.Chart.Legend.Width / co.Chart.PlotArea.InsideWidth.
Also coping with lines underlapping and text boxes overlapping the possible legend positions: same idea, more complexity.
Question
Obviously, all this works better if the legend is as small as possible, as that gives a greater likelihood of finding a location with zero ’lapping.
If .Legend.Width is too small, then the individual legend texts (the Series.Name’s) wrap onto ≥2 lines, which isn’t wanted. So VBA could interval bisect to find the smallest .Legend.Width for which there isn’t line wrapping. But how can the VBA code ‘see’|‘detect’|‘know’ of the existence of the line wrapping?
And mutatis mutandis for .Legend.Height: if that’s too small, some legend entries aren’t shown. How can the VBA code ‘see’|‘detect’|‘know’ that a height is too small?
Thank you.
PS: I expect that the correct answer is that “VBA cannot ‘see’|‘detect’|‘know’ either of these.” Please refute this expectation.
If you create your own legend, using a text box, you have better options when it comes to sizing and flow control. This will create a new set of challenges, but it might be easier to handle.

Excel VBA : Use the color of a shape in an If/Then case

I have created a chart on Excel using macros. Each of the shapes on the chart is filled with a color according to its category. I was wondering if it is possible to use the color of the shapes in an If/Then case to perform different actions, such as displaying the shapes with specific colors only.
For example, something similar to:
If shape.Fill.ForeColor.SchemeColor = 1 Then
shape.delete
I have tried that, but it doesn't seem to do anything to my chart. Does anyone have an idea of how to do it?
Thank you !!
Did you try checking the color with the corresponding RGB value? Since SchemeColor depends on the current color scheme it might be looking for a different color than you'd expect

Highcharts: Polar columns datalabels inside position

I'm trying to get values (datalabels) of a columns polar chart INSIDE the actual column, and not on top of it. I've set inside: true property but it does not seem to have any effect, although it works pretty nicely while using a regular stacked columns chart for example.
Here is the fiddle showing the issue: http://jsfiddle.net/deurk/BeVyt/2/
Ideally, I'd like to have the datalabels in their "shares" if there is enough space, with white color. Does anyone have a workaround for this?
Thanks!
Indeed it looks like a bug, so I've reported it here https://github.com/highslide-software/highcharts.com/issues/1688