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:
-
- Do right-click on smart-table [assosiated with power query]
-
- 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 ?
CodePudding user response:
Thanks to @ALeXceL for moving me to available option.
Application.CommandBars.ExecuteMso "PowerQueryLaunchQueryEditor"
; see about CommandBars.ExecuteMso and how to identify idMsoONCE 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
Revised my "Target/preferred scenario"(from initial post); decided to use QAT ShortCut as it was recommended in comments )