Home > front end >  Opening Power Query editor programmatically
Opening Power Query editor programmatically

Time:08-05

I'm improving my own tools for preparing corporate reports in Excel.

Current exercise: to reduce clicks count related to Power Query editor opening.

Current regular scenario once it needs to change existing query (see screenshot; sorry for non-EN locale in it)

  • A. Go to ribbon menu "Data"
  • B. Click "Book queries"
  • C. In "Book queries" pane select relevant query
  • D. Do double-click on it

Target/preferred scenario:

    1. Do right-click on smart-table [assosiated with power query]
    1. Click on my(custom) context menu item for opening Power Query editor

For now:

  • I know how to add my(custom) context menu item, available only over the smart-table
  • I know how to handle this menu item click in VBA
  •    check is it really clicked over the smart-table
    
  •    check/find associated query name
    

Problem: I haven`t found any way how to start/open Power Query editor [for specific query] from VBA code [or what ever else].

Thoughts:

  • looks like Power Query editor is not available via Excel Application Object Model
  • may be it would be available for automation via Commands("...") collection ?
  • may be it has representation in VSTO via C# ?
  • other ideas ?

enter image description here

CodePudding user response:

Thanks to @ALeXceL for moving me to available option.

  1. Application.CommandBars.ExecuteMso "PowerQueryLaunchQueryEditor"; see about CommandBars.ExecuteMso and how to identify idMso

  2. ONCE active/selected cell is inside smart table assosiated to query THEN editor opens on this query; thats why there is no "input parameter" like QueryName

  3. Revised my "Target/preferred scenario"(from initial post); decided to use QAT ShortCut as it was recommended in comments )

  • Related