Can NodeXL routines be accessed from VBA?

May 27, 2014 at 3:57 AM
I have written VBA routines that implement Suurballes Edge disjoint and Node disjoint path algorithms referencing the named ranges in the NodeXL template.

In particular, at the end of the VBA routines, I would like the Refresh Graph function to be executed so the Suurballe analysis is immediately visible.

If this is possible, how would it be coded?

May 27, 2014 at 4:47 PM
Edited May 27, 2014 at 4:54 PM
The custom NodeXL code added to the Excel workbook is not accessible from VBA.

A long time ago, I tried to work around this limitation by programmatically pressing a button in the NodeXL ribbon tab from VBA code. My effort failed, because the NodeXL ribbon tab was not made available in the Excel object model. (I believe I was looking through the CommandBars collection). You can try that yourself to see if anything has changed in recent versions of Excel, or in case I was overlooking something.

Another thing you might investigate is Microsoft's "UI Automation," which is an API meant for interacting with the UI controls of other applications. I've never tried it. If you get it to work for NodeXL controls, please let me know.

-- Tony
Feb 5, 2015 at 12:56 PM
I spent a while looking for solutions to this problem
You can use the Application Send keys commands to get to the ribbon button. See the following to get there:

Sub RefreshGraph()
'Forces ribbon to home to ensure common reference
Application.SendKeys ("%H%")

'Naviagate to Nodexl ribbon
Application.SendKeys ("%Y")

'Select the Refresh graph button
Application.SendKeys ("Y5%")

End Sub

I hope that helps!