Override DisabledCommandTypes

Override DisabledCommandTypes

LarsBJepsen
Advocate Advocate
557 Views
2 Replies
Message 1 of 3

Override DisabledCommandTypes

LarsBJepsen
Advocate
Advocate

Hi,

 

I have this code which disables all Commands that can affect the geometry of the model, including running macros. I would like to be able to run macros while all other commands are disabled, so the question is if there is any way to override the disabledcommandtypes to enable running of macros while all other commands in "kEditMaskCmdType" are disabled?

 

/Lars 

 

Sub Noneditble()

Dim oDoc As Document
Set oDoc = ThisApplication.activedocument

oDoc.DisabledCommandTypes = kEditMaskCmdType

End Sub
0 Likes
558 Views
2 Replies
Replies (2)
Message 2 of 3

LarsBJepsen
Advocate
Advocate

I have the code below, that should do some of what I Want, but it's not working - i get an error at line13 (oDoc.DisabledCommandList.Remove (oPrintCmd)). oDoc.DisabledCommandTypes = 4 ,disables file operations like save and print, and then i try to enable the print command again.

 

Sub ReadOnly()

Dim oDoc As Document
Set oDoc = ThisApplication.ActiveDocument

oDoc.DisabledCommandTypes = 4

Dim oPrintCmd As ControlDefinition
Set oPrintCmd = ThisApplication.CommandManager.ControlDefinitions.Item("AppFilePrintCmd")

oDoc.DisabledCommandList.Remove (oPrintCmd)

End Sub

 

0 Likes
Message 3 of 3

LarsBJepsen
Advocate
Advocate

One step closer, but still not enabling the print command. 

Sub test()

Dim oDoc As Document
Set oDoc = ThisApplication.ActiveDocument

oDoc.DisabledCommandTypes = 4

Dim controlDef As ControlDefinition

    For Each controlDef In ThisApplication.CommandManager.ControlDefinitions

        If (controlDef.InternalName = "AppFilePrintCmd") Then

            If controlDef.Enabled = False Then
                controlDef.Enabled = True
            End If
                   
            Exit For

       End If

 Next

End Sub
0 Likes