How to Change Excel Power Query Paramaters with VB

2019-08-30 08:47发布

问题:

How to change Excel PowerQuery Paramaters with VBA?

i.e. These Paramaters:

Right now the Paramater has a value of 8, and is used in refreshing all other power queries. How can I change this paramater with VBA?

The Macro recorder does not show anything.

回答1:

Thanks to QHarr, I figured it out. Simply edit the Power Query M Code - the Parameter value is first item in the Code.

e.g.

5 meta [IsParameterQuery=true, Type="Number", IsParameterQueryRequired=true]

5 is the Parameter Value.

To edit, use the "Formula" Property e.g.

ThisWorkbook.Queries([ParameterName]).Formula = 'New code here