ACC2: How to Use OLE Automation to Modify MS Graph ObjectID: Q119469
|
Moderate: Requires basic macro, coding, and interoperability skills.
This article describes how to use OLE Automation to modify a Microsoft
Graph version 5.0 graph's title and hide or show the graph's legend.
This article assumes that you are familiar with Access Basic and with
creating Microsoft Access applications using the programming tools provided
with Microsoft Access. For more information on Access Basic, please refer
to the "Building Applications" manual.
Text Box
-------------
Name: MyTitle
Command Button
---------------------
Name: Title
Caption: Show Caption
Sub Title_Click ()
Dim The_title As String
'--------------------------------------------------------------
' This function reads the text box. If it is null or blank, it
' supplies a generic title, otherwise it adds a title and sets
' the caption to the text box's contents.
'--------------------------------------------------------------
If IsNull(Me![MyTitle]) Or Me![MyTitle] = "" Then
The_title = "No Title"
Else
The_title = Me![MyTitle]
End If
If Me![Title].Caption = "Show Title" Then
Me![Embedded13].Object.Application.Chart.Hastitle = -1
Me![Embedded13].Object.Application.Chart.Charttitle.Caption = _
The_title
Me![Title].Caption = "Hide Title"
Else
Me![Embedded13].Object.Application.Chart.Hastitle = 0
Me![Title].Caption = "Show Title"
End If
End Sub
Option Explicit
Name: Legend
Caption: Show Legend
Sub Legend_Click ()
'----------------------------------------------------------
' If the legend is not present, show it, otherwise hide it.
'----------------------------------------------------------
If Me![Legend].Caption = "Show Legend" Then
Me![Embedded13].Object.Application.Chart.Haslegend = -1
Me![Legend].Caption = "Hide Legend "
Else
Me![Embedded13].Object.Application.Chart.Haslegend = 0
Me![Legend].Caption = "Show Legend"
End If
End Sub
Option Explicit
Microsoft Access "Building Applications," version 2.0, Chapter 8, "Events,"
pages 183-201, and Chapter 13, "Communicating with Other Applications,"
pages 281-311
For more information about OLE Automation, search for "OLE Automation," and
then "Interoperability with Microsoft Word and Microsoft Excel (Common
Questions" using the Microsoft Access Help menu.
Additional query words: link embed
Keywords : kbtool IntpGrph
Version : 2.0
Platform : WINDOWS
Issue type : kbhowto
Last Reviewed: April 6, 1999