iamareplicant
Programmer
I have an Access app that has a bound control tied to an Excel chart in a workbook.
Here is code that is in the Excel chart that captures the user's click event on a histogram:
OK, what I would like to be able to do (and I dont know if it is even possible) is to have this exact same functionality within my Access bound control where this chart is displayed.
Here is code that cannot ever run, but depicts the essence what I would like to have happen:
There ya have it. Any help in how to get the chart within my bound Access control to behave as it does in its native/Excel environment would be much appreciated. Or, if you know, let me know that it is impossible.
TIA
JBG
Here is code that is in the Excel chart that captures the user's click event on a histogram:
Code:
Public Sub Chart_MouseUp(ByVal Button As Long, ByVal Shift As Long, ByVal x As Long, ByVal y As Long)
Dim ElementID As Long, Arg1 As Long, Arg2 As Long
Dim myX As Variant, myY As Double
With ActiveChart
.GetChartElement x, y, ElementID, Arg1, Arg2
If ElementID = xlSeries Or ElementID = xlDataLabel Then
If Arg2 > 0 Then
myX = WorksheetFunction.Index(.SeriesCollection(Arg1).XValues, Arg2)
myY = WorksheetFunction.Index(.SeriesCollection(Arg1).Values, Arg2)
‘ g_strClickedVal = myX
‘ frmValue.Show
End If
End If
End With
End Sub
OK, what I would like to be able to do (and I dont know if it is even possible) is to have this exact same functionality within my Access bound control where this chart is displayed.
Here is code that cannot ever run, but depicts the essence what I would like to have happen:
Code:
Private Sub ole0A_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim ElementID As Long, Arg1 As Long, Arg2 As Long
Dim myX As Variant, myY As Double
Dim objExcelApp As Excel.Application
Dim objExcelWB As Excel.Workbook
Dim objExcelChart As Excel.Chart
Dim objExcelSheet As Excel.Worksheet
Dim objExcelSheet2 As Excel.Worksheet
Dim objCH As Excel.ChartObject
Dim objChart As Object
Set objExcelApp = CreateObject("Excel.Application")
objExcelApp.Visible = False
Set objExcelWB = objExcelApp.Workbooks.Open _
(GetSpecialfolder(CSIDL_DESKTOP) & "\ACT Excel\" & Me.cboMain0 & ".xls")
Set objExcelChart = objExcelWB.Charts(Me.cboMain0 & "CHART")
Set objExcelSheet = objExcelWB.Sheets("Sheet1")
Set objCH = objExcelSheet.ChartObjects(1)
Set objExcelChart = objCH.Chart
Set objExcelChart = ole0A.Object
'ole0A.Object
With objChart
.GetChartElement X, Y, ElementID, Arg1, Arg2
If ElementID = xlSeries Or ElementID = xlDataLabel Then
If Arg2 > 0 Then
myX = WorksheetFunction.Index(.SeriesCollection(Arg1).XValues, Arg2)
myY = WorksheetFunction.Index(.SeriesCollection(Arg1).Values, Arg2)
'g_strClickedVal = myX
'frmValue.Show
MsgBox myX
End If
End If
End With
Set objExcelChart = Nothing
Set objExcelWB = Nothing
objExcelApp.Quit
Set objExcelApp = Nothing
End Sub
There ya have it. Any help in how to get the chart within my bound Access control to behave as it does in its native/Excel environment would be much appreciated. Or, if you know, let me know that it is impossible.
TIA
JBG