An embedded Excel chart in Powerpoint MouseMove not working...

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:

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
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!
 
Last edited:
How are you copying the code into PowerPoint? Where are you pasting the code?

Do you want the mouse-move code to work in PowerPoint design mode or in presentation mode?

In design mode you could use paste special to paste the chart as a Microsoft Excel Chart Object instead of the default Microsoft Office Graphic Object. Then if you double click the chart, it is activated within PowerPoint as an Excel object, asking you to enable macros, and the chart events will work. When you finish and exit the Excel environment, the chart will have resized and moved in the slide.

You could instead insert an object, from the file containing the chart. Double clicking will again be activated in PowerPoint as an Excel object, asking again to enable macros, and the chart events will also work. Exiting Excel will not resize or reposition the chart.

In presentation mode, you can't activate the Excel objects no matter how they are inserted on the slide. You could probably put a button on the slide that you can click to open the file in Excel, where the events will work. But this is interacting with the original Excel workbook, not with the presentation.
 
Upvote 0

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top