XLConnect
  • XLConnect Documentation
  • Using XLConnect
    • Getting Started
    • Using XLConnect
    • Manage Users
    • Manage Your Subscription (Owners)
    • XLConnect Security
    • Troubleshooting
  • Developing with XLConnect
    • Getting Started
    • The Bigger Picture
    • Import Scripts
    • Scripts
    • Cloud Systems
    • Javascript
      • Javascript Studio
      • Javascript language
      • Calling API's with HTTP Requests
      • Working with JSON data
      • The xlc object
      • Advanced Javascript
    • Modules
      • HTTP module
      • FILE module
    • Maps
    • JSON Data Format
    • Data Lake
    • Excel modelling
    • VBA
    • The XLConnect API
  • Reference
    • Change log
Powered by GitBook
On this page
  • To use this in your workbook:
  • Available methods
  1. Developing with XLConnect

VBA

Control scripts from VBA

PreviousExcel modellingNextThe XLConnect API

Last updated 1 year ago

The XLConnect add-in can be controlled from VBA for a better user experience when users click on a button, doubleclick a cell, change a value etc.

Below is an example that runs the script named "Pull TrialBalance"

Sub PullConnections()
    Set xlc = Application.COMAddIns("XLConnect").Object
    xlc.fetchData "Pull TrialBalance"
End Sub

To use this in your workbook:

  • "Connections"

  • On the Insert ribbon of Excel, insert an Icon

  • Right-click the icon and select Assign Macro...

  • In the Assign Macro screen, select New

  • This should bring you to the VBA editor. If not, press ALT-F11.

  • Paste in the two lines so your code looks like this:

Sub Graphic2_Click()
    Set xlc = Application.COMAddIns("XLConnect").Object
    xlc.fetchData "Connections"
End Sub

Make sure the name of the VBA method corresponds to the name in the Assign Macro editor in Excel (in this case Graphic2_Click).

  • Go back to Excel and click the icon, that should now run the Graphic2_Click VBA method, that will execute the Connections script.

This is how simple it is to execute a script by clicking an icon.

Available methods

Import script