AppBrowserCollapseChildrenCmd

AppBrowserCollapseChildrenCmd

dg2405
Advocate Advocate
519 Views
6 Replies
Message 1 of 7

AppBrowserCollapseChildrenCmd

dg2405
Advocate
Advocate

Why does the Command

ThisApplication.CommandManager.ControlDefinitions.Item("AppBrowserCollapseChildrenCmd").Execute

not work? I think it should collapse alle Nodes in the Browser, but nothing happens!

0 Likes
520 Views
6 Replies
Replies (6)
Message 2 of 7

GeorgK
Advisor
Advisor

 

Dim oControlDef As ControlDefinition
Set oControlDef = ThisApplication.CommandManager.ControlDefinitions.Item("AppBrowserCollapseChildrenCmd")
Call oControlDef.Execute

 

0 Likes
Message 3 of 7

dg2405
Advocate
Advocate

Hey george,

thanks for your reply!

Is your code not the same as mine?

When i run your code nothing happens too. Does your code work at your assemblies?

0 Likes
Message 4 of 7

dg2405
Advocate
Advocate

I found that the controldefinition is disabled with following code:

 

Debug.Print oControlDef.Enabled

Trying to enable it with following code not work:

 

oControlDef.Enabled=True

Any ideas?

 

0 Likes
Message 5 of 7

GeorgK
Advisor
Advisor
Sorry:

Public Sub Test()
Set oDoc = ThisApplication.ActiveEditDocument

Dim oTopNode As BrowserNode
Set oTopNode = oDoc.BrowserPanes.ActivePane.TopNode
Dim oNode As BrowserNode

For Each oNode In oTopNode.BrowserNodes
'If the node is visible and expanded, collapse it
If oNode.Visible = True And oNode.Expanded = True Then
oNode.Expanded = False
End If
Next
End Sub
0 Likes
Message 6 of 7

dg2405
Advocate
Advocate

Your code only collapse the nodes under the TopNode, so i have to write a recursive function...

But why is the command "AppBrowserCollapseChildrenCmd" disabled? This command is very fast, a recursive function taks a little time in large assemblies.

0 Likes
Message 7 of 7

dg2405
Advocate
Advocate

I found out that the command "AppBrowserCollapseAllCmd" work when i make a rmb on to the browser bevor i start the code. My question is: how can i get rmb menu by api? I tried following code, to simulate a mouse click but the command work almost when i start the macro the 2nd time.

 

 

Private Declare PtrSafe Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal Y As Long) As Long
Private Declare PtrSafe Sub mouse_event Lib "user32" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)
Private Const MOUSEEVENTF_RIGHTDOWN As Long = &H8
Private Const MOUSEEVENTF_RIGHTUP As Long = &H10
Sub rmb()
    SetCursorPos 15, 215
    mouse_event MOUSEEVENTF_RIGHTDOWN, 0&, 0&, 0&, 0&
    mouse_event MOUSEEVENTF_RIGHTUP, 0&, 0&, 0&, 0&
End Sub

Any suggestions?

 

 

 

0 Likes