JosephClarke
New Member
- Joined
- Jul 24, 2015
- Messages
- 3
Hi,
Its my first post, so forgive me if I have broken any rules. I tried to find this answer on the board, but couldn't.
I have an excel file, with a chart, with the following code:
The code effectively creates a pop-up text box whenever one of the bars on the chart is highlighted, and it pulls the date (which is the X axis), the value, and then whatever is in column c as well
My issue is, this is a report that is to go into a presentation, though it would appear that the Chart_MouseMove isn't working once I put this into a powerpoint presentation (and I've copied the coding across to the chart, as for some reason the coding doesn't automatically transfer over)
It works like a dream in excel, but I need to be able to put this into powerpoint, which it currently does not.
Any ideas how I can get this to work once from powerpoint?
Additional Info: Excel and Powerpoint are both 2010.
Thanks for the help!
Its my first post, so forgive me if I have broken any rules. I tried to find this answer on the board, but couldn't.
I have an excel file, with a chart, with the following code:
Code:
Private Sub Chart_Activate()
ActiveChart.ChartArea.Select
ActiveChart.SeriesCollection(1).Select
End Sub
Private Sub Chart_MouseMove(ByVal Button As Long, ByVal Shift As Long, ByVal x As Long, ByVal y As Long)
Dim ElementID As Long
Dim Arg1 As Long
Dim Arg2 As Long
Dim chart_data As Variant
Dim chart_label As Variant
Dim last_bar As Long
Dim chrt As Chart
Dim ser As Series
Dim projectslive As String
Dim cRow As Long
Dim datestuff As Long
Dim nRows As Long
On Error Resume Next
Me.GetChartElement x, y, ElementID, Arg1, Arg2
Set chrt = ActiveChart
Set ser = ActiveChart.SeriesCollection(1)
chart_data = ser.Values
chart_label = ser.XValues
cRow = 2
Set txtbox = ActiveSheet.Shapes("hover")
If ElementID = xlSeries Then
If Err.Number Then
datestuff = chart_label(Arg2)
chart_label(Arg2) = Format(chart_label(Arg2), "mmm yyyy")
Do Until Sheets("Data").Cells(cRow, 1).Value = ""
If Sheets("Data").Cells(cRow, 1).Value = datestuff Then
projectslive = Sheets("Data").Cells(cRow, 3).Value
nRows = Sheets("Data").Cells(cRow, 34).Value
nRows = 50 + (nRows * 16)
End If
cRow = cRow + 1
Loop
Set txtbox = ActiveSheet.Shapes.AddTextbox(msoTextOrientationHorizontal, 0, 0, 400, nRows)
txtbox.Top = 0
txtbox.Left = 0
txtbox.Name = "hover"
txtbox.Fill.Solid
txtbox.Fill.ForeColor.SchemeColor = 22
txtbox.Fill.TwoColorGradient msoGradientHorizontal, 1
txtbox.Line.DashStyle = msoLineSolid
chrt.Shapes("hover").TextFrame.Characters.Text = " " & chart_label(Arg2) & ": " & Application.WorksheetFunction.Text(chart_data(Arg2), "??.?" & "%") & Chr(10) & Chr(10) & projectslive
With chrt.Shapes("hover").TextFrame.Characters.Font
.Name = "Calibri"
.Size = 12
.Bold = True
.ColorIndex = 56
End With
With chrt.Shapes("hover").TextFrame.Characters(Start:=51, Length:=6).Font
.Name = "Calibri"
.Size = 22
.Bold = True
.ColorIndex = 30
End With
With chrt.Shapes("hover").TextFrame.Characters(Start:=41, Length:=9).Font
.Name = "Calibri"
.Size = 20
.Bold = True
.ColorIndex = 56
End With
' last_bar = Arg2
End If
txtbox.Left = 0
txtbox.Top = 0
Else
txtbox.Delete
'ser.Interior.ColorIndex = 16
End If
End Sub
My issue is, this is a report that is to go into a presentation, though it would appear that the Chart_MouseMove isn't working once I put this into a powerpoint presentation (and I've copied the coding across to the chart, as for some reason the coding doesn't automatically transfer over)
It works like a dream in excel, but I need to be able to put this into powerpoint, which it currently does not.
Any ideas how I can get this to work once from powerpoint?
Additional Info: Excel and Powerpoint are both 2010.
Thanks for the help!
Last edited: