Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Disabling "Save Copy As" Button - VBA

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
Tiffany_Hayden_
324 Views, 3 Replies

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

Disabling "Save Copy As" Button - VBA

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

Labels (1)
  • -
3 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

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

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

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. 

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

@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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report