Message 1 of 6
Cancel a command

Not applicable
05-23-2008
02:26 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I want to cancel every edit command when a inventor document is read-only and give the user a message. (such as ESC) The message i get but the command isn't cancelled. (wrong commandname "FDTrasparentCancel" ?)
How can I do this?
Code:
Private Sub mobjUserInputEvents_OnActivateCommand(ByVal CommandName As String, ByVal Context As NameValueMap)
On Error GoTo Errorhandler
Dim fs As New FileSystemObject
Dim oFile
Dim oINVDoc As Inventor.Document
Set oINVDoc = objInventorApp.ActiveDocument
If UCase(Left(oINVDoc.FullDocumentName, 3)) = "T:\" Then
'check of is file read_Only
Set oFile = fs.GetFile(oINVDoc.FullDocumentName)
If oFile.Attributes = 1 Or oFile.Attributes = 33 Then
objInventorApp.CommandManager.PromptMessage "Let op Command: " & oINVDoc.DisplayName & " is Read_Only en kan niet gewijzigd worden!", vbExclamation
'Cancel edit command
Dim oControlDef As ControlDefinition
Set oControlDef = objInventorApp.CommandManager.ControlDefinitions.Item("FDTrasparentCancel")
oControlDef.Execute
End If
End If
Exit Sub
Errorhandler:
GeneralErrorHandler "mobjUserInputEvents_OnActivateCommand"
End Sub
How can I do this?
Code:
Private Sub mobjUserInputEvents_OnActivateCommand(ByVal CommandName As String, ByVal Context As NameValueMap)
On Error GoTo Errorhandler
Dim fs As New FileSystemObject
Dim oFile
Dim oINVDoc As Inventor.Document
Set oINVDoc = objInventorApp.ActiveDocument
If UCase(Left(oINVDoc.FullDocumentName, 3)) = "T:\" Then
'check of is file read_Only
Set oFile = fs.GetFile(oINVDoc.FullDocumentName)
If oFile.Attributes = 1 Or oFile.Attributes = 33 Then
objInventorApp.CommandManager.PromptMessage "Let op Command: " & oINVDoc.DisplayName & " is Read_Only en kan niet gewijzigd worden!", vbExclamation
'Cancel edit command
Dim oControlDef As ControlDefinition
Set oControlDef = objInventorApp.CommandManager.ControlDefinitions.Item("FDTrasparentCancel")
oControlDef.Execute
End If
End If
Exit Sub
Errorhandler:
GeneralErrorHandler "mobjUserInputEvents_OnActivateCommand"
End Sub