Copy Chart (like in default context menu)

emorris1000

Registered User.
Local time
Today, 11:03
Joined
Feb 22, 2011
Messages
125
When you haven't added a custom context menue to a chart you get an option for "copy" which gives you a nice chart you can move over to word or wherever and then manipulate further.

I've added a custom context menu to the graphs, but I would really like to keep the "Copy Chart" option that exists in the default context menu. Does anyone know how to do this?
 
If your using MS2003 or earlier I'm assuming you made the custom context menu using the built in toolbar which I have already forgotten how to do since 2007 and up simply killed that wonderful tool. But if you are you should be able to add the Cut/Copy/Paste commands.

Otherwise, you can use VBA to add commands to your context menu. Here is a general function:

Code:
Function UpdateShortCut(CmdNameBar As String, CtlAction As String, CtlCap As String, CtlFaceID As Integer)
Dim CBar As CommandBar, CBarCtl As CommandBarControl

Set CBar = CommandBars(CmdNameBar)
   Set CBarCtl = CBar.Controls.Add(Type:=msoControlButton)
   With CBarCtl
      
      .BeginGroup = True
      .FaceId = CtlFaceID
      .caption = CtlCap
      .OnAction = CtlAction
   End With

Set CBarCtl = Nothing
Set CBar = Nothing

End Function

To use it:

Code:
UpdateShortCut("CustContextMenuName", "Copy", "Copy Chart", 19)
You could run it from the Immediate Window or from a button or some such.
 
That's interesting, I didn't think people added menus like that. I just did it with the Macro's and tied it to the "shortcut menu" property (this is in 2007/2010).

I'm not really sure about managing the context menu this way since it's so radically different from how the rest of mine are managed. I'll look through the documentation for the command bar though.

I was just thinking to reference the chart object and copy it, I just wasn't sure if there was some special way needed to copy it.

edit: Wait are you talking about the old school command bar across the top of the window/thing that the ribbon replaced? I don't need that. I was talking about a 'right-click' context menu that pops up.

edit2: hrm I guess it still applies since they are all command bar menus? Gonna go do some reading.
 
Your right, MS wants people to use Macros in the new versions. In the very old version there were tool bars but that does not apply to you. I really don't like Macros so I use VBA for everything. You should be able to add the Copy command to your Macro, but if not, you still can use the VBA code I provided to add the command.
 

Users who are viewing this thread

Back
Top Bottom