Disabling "Save Copy As" Button - VBA

Disabling "Save Copy As" Button - VBA

Tiffany_Hayden_
Collaborator Collaborator
460 Views
3 Replies
Message 1 of 4

Disabling "Save Copy As" Button - VBA

Tiffany_Hayden_
Collaborator
Collaborator

I was curious if anyone has run into the need to grey out the "Save Copy As" functionality under File? 

 

I tried to run the same code that I'm using to disable other commands but it doesn't seem to disable the command. I'm wondering if I have to do something different since it's an embedded command? Any help would be appreciated. 

 

 

Public Sub DisableAssemblySaveCopyAsCmd() '(oAssyDoc As AssemblyDocument)
    Dim oDrawDoc As DrawingDocument: Set oDrawDoc = ThisApplication.ActiveDocument
    '***********************************************************************************************************************************
    ' DISABLES THE MIRROR COMMAND WITHIN A SPECIFIED ASSEMBLY DOCUMENT
    '***********************************************************************************************************************************
    Dim oCtrlDef As ControlDefinition
    If oDrawDoc Is Nothing Then Exit Sub
    For Each oCtrlDef In ThisApplication.CommandManager.ControlDefinitions
        If oCtrlDef.DisplayName = "&Save Copy As..." Then
            oCtrlDef.Enabled = False
            'Call oDrawDoc.DisabledCommandList.Add(oCtrlDef)
        End If
    Next
End Sub

 

 

TiffanyHaydenSWQYG_0-1680722602434.png

 

 

Tiffany Hayden
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature

0 Likes
Accepted solutions (2)
461 Views
3 Replies
Replies (3)
Message 2 of 4

Tiffany_Hayden_
Collaborator
Collaborator
Accepted solution

Found the issue! the display name is "Save Copy"

Public Sub DisableAssemblySaveCopyAsCmd() '(oAssyDoc As AssemblyDocument)
    Dim oDrawDoc As DrawingDocument: Set oDrawDoc = ThisApplication.ActiveDocument
    '***********************************************************************************************************************************
    ' DISABLES THE SAVE COPY AS COMMAND WITHIN A SPECIFIED DOCUMENT
    '***********************************************************************************************************************************
    Dim oCtrlDef As ControlDefinition
    If oDrawDoc Is Nothing Then Exit Sub
    For Each oCtrlDef In ThisApplication.CommandManager.ControlDefinitions
        If oCtrlDef.DisplayName = "Save Copy" Then
        'If InStr(oCtrlDef.DisplayName, "Save Copy") > 0 Then
            Debug.Print oCtrlDef.DisplayName & ", " & oCtrlDef.DescriptionText
            oCtrlDef.Enabled = False
            'Call oDrawDoc.DisabledCommandList.Add(oCtrlDef)
        End If
    Next
End Sub

 

Tiffany Hayden
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature

0 Likes
Message 3 of 4

Michael.Navara
Advisor
Advisor
Accepted solution

Easier and language independent way is to use InternalName of button definition.

 

 

Dim cmdInternalName = "AppFileSaveCopyAsCmd"
ThisApplication.CommandManager.ControlDefinitions(cmdInternalName).Enabled = False

 

 

What is the internal name of command you can get from EventWatcher (tool from Inventor SDK).

Select UserInputEvents.OnActivateCommand and click the button in Inventor. In log window the internal name is displayed. 

0 Likes
Message 4 of 4

Tiffany_Hayden_
Collaborator
Collaborator

@Michael.Navara  Very Cool! Thanks so much! 

Tiffany Hayden
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature

0 Likes