- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi There,
I came across this situation and it has puzzled me, if you can share your thoughts and experience, would be greatly appreciated
when I use command manager like below (it could be any command, this is an example)
ThisApplication.CommandManager.ControlDefinitions.Item("GeomToDXFCommand")
if its sitting in a module in VBA and you run it as macro, it works fine without any issue, however , if you insert a userform and place the code in a command button on the form, it wont work, and it wont give you any warning or error as if it's run properly but it does not in fact fire up the command. see below
Private Sub CommandButton1_Click()
Dim pd As PartDocument
Set pd = ThisApplication.ActiveDocument
Dim oDef As PartComponentDefinition
Set oDef = pd.ComponentDefinition
pd.SubType = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}"
Dim F As Face
Set F = pd.ComponentDefinition.SurfaceBodies(1).Faces(2)
Call pd.SelectSet.Select(F)
Dim cd As ButtonDefinition
Set cd = ThisApplication.CommandManager.ControlDefinitions.Item("GeomToDXFCommand")
' To void user interaction
'Call ThisApplication.CommandManager.PostPrivateEvent(PrivateEventTypeEnum.kFileNameEvent, "C:\DXF\Test.dxf")
Call cd.Execute
End Sub
same code works perfectly fine when its place in a module (see below)
any idea as to whether or not this is a normal behavior or if there is any missing steps.
Regards
Ali
Solved! Go to Solution.