I have an excel file with a web query in it. Right now i can execute
the webquery by doing one of the following methods
chose the menu item Data-> Import External Data - > Edit Query
click the Edit query button in the external data tool bar.
Right click on the cell on the excel and say Edit query.

When i do any of the above excel brings up a window (which is
essentially internet explorer with title Edit Web Query) with a
predefined url in there.

I am trying to automate this process so that this window comes up
automatically. I wrote the following macro
Application.Sheets(1).Range("A3").Activate
Set cmndButton = Application.CommandBars.FindControl(Type:= _
msoControlButton, ID:="1950")
cmndButton.Visible = True
cmndButton.Execute

but it is failing with the error
err.Number : -2147467259
err.Description Method 'Execute' of object '_CommandBarButton' failed
err.HelpContext 1000440
err.Source VBAProject
err.LastDllError 0
err.HelpContext 1000440

This error happens if i click on the edit query button on the tool bar
or if i put the code in the activate event of the worksheet. But right
clickng on the cell and chosing the menu item Edit Query or chosing
menu item Data-> Import External Data - > Edit Query brings up the
popup window as it should be.

Any help is greatly appreciated.

Thanks