Author Topic: Ribbon support  (Read 1376 times)

crusby

  • Newbie
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Ribbon support
« on: November 15, 2013, 09:43:42 AM »
Does PyXLL support the Ribbon? I don't see anything about this in the documentation, in which case please may I add this as a feature request?  It's supported by ManagedXLL (for C# code, obviously!), but you could use this as a reference implementation...

Thanks

Tony

  • Administrator
  • Hero Member
  • *****
  • Posts: 610
  • Karma: +14/-1
    • View Profile
Re: Ribbon support
« Reply #1 on: November 15, 2013, 10:19:21 AM »
Hi,

no it doesn't at the moment. If you want to create a ribbon menu using python you can do it using win32com, though. There are a few examples on the web including this one http://markmail.org/download.xqy?id=5q3rh3wwi7hwopbx&number=1.

There's also some code in the forum (search for RTD and look for the function '_register') that shows how to register a python com addin when pyxll starts. Using that and win32com it shouldn't be too hard to add controls to the ribbon.

Thanks for the feedback. I'll look at this for a future release or maybe create a new example using win32com as described above.

Best regards,
Tony

crusby

  • Newbie
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: Ribbon support
« Reply #2 on: October 23, 2015, 09:29:24 AM »
Hi Tony,

I just thought I'd give an update on this.

We have survived without a ribbon until now, but we are considering upgrading to Excel 2013.  We have discovered an amusing(?) bug whereby running Excel 2013 with Bloomberg installed somehow deletes the "Add-Ins" menu.  No solution to this yet... but I thought I'd revisit the ribbon idea as a potential workaround.

I did spend a while looking at the win32com idea, and, although I eventually got it to work, it was a bit messy because it does register an add-in which (unless you're careful) gets left behind in your Excel install. Also, it wasn't clear that I could get the pythom com server to work successfully without installing the components on each individual users' machine - which would be a bit of an overhead.

Instead, I added some xml to an xlam (which we already load), using the Office Custom UI Editor (http://openxmldeveloper.org/blog/b/openxmldeveloper/archive/2006/05/26/customuieditor.aspx).

I then made the onAction event call xlRibbonOnAction, and set the button id to the name of an pyxll xl_macro function. A 3 line vba function in said xlam then on-calls to PyXLL via Application.Run.

Obviously, native support for the ribbon in PyXLL would still be best (we can't call PyXLL->Reload from the ribbon, for instance).  But as a workaround, it's not too bad.

Chris

Tony

  • Administrator
  • Hero Member
  • *****
  • Posts: 610
  • Karma: +14/-1
    • View Profile
Re: Ribbon support
« Reply #3 on: October 25, 2015, 08:10:37 PM »
Hi Chris,

I've actually been working on ribbon support, among other things, for the next major PyXLL version (3). It's probably at a staged where you could use it. You have to specify an xml file in the config and in the xml use python function names (including any modules/packages) as the callbacks.

I'll create a beta release and upload it for you to try out. No updated docs as yet, but there is an example included.

I'll PM you with the details of how to download it.

Best regards,
Tony