Cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted

Handle OnFileSaveAsUI and cancel save

Solution Partner Valued Contributor Solution Partner Valued Contributor
Solution Partner Valued Contributor

Hi community,

 

I try to handle the OnFileSaveAsUI event in order to define the filename on first save if a name is define by another tool.

 

Everything works fine except when the user cancel the save, in the UI.

In that case a message appears saying for exemple 'Part1 cannot be saved'.

 

Code used :

 

    Private Sub OnFileSaveAsUI(ByRef Filename As String, ByRef AppendToTitle As String) Implements SolidEdgeFramework.ISEFileUIEvents.OnFileSaveAsUI

        If Public_Vars.CustomFilename <> "" Then
            AddOrRemoveEventHandlers(False)

            Dim linksUpdateOption As SolidEdgeFramework.LinksUpdateOption
            Dim selectedfilter As Integer
            Dim strSaveAsFileName As String
            linksUpdateOption = SolidEdgeFramework.LinksUpdateOption.igNoLinksUpdate

            Try
                strSaveAsFileName = MyAddIn.Instance.Application.GetSaveAsFileName(linksUpdateOption, selectedfilter, InitialFilename:=Public_Vars.CustomFilename , FileFilter:="default")
                If Not strSaveAsFileName = "False" Then
                    Filename = strSaveAsFileName
                    Public_Vars.CustomFilename = ""
                Else
                    '## HOW TO EXIT WIHOUT MESSAGE ##

                    Filename = Nothing AppendToTitle = Nothing Public_Vars.CustomFilename = "" End If AddOrRemoveEventHandlers(True) Catch ex As Exception Public_Vars.CustomFilename = "" AddOrRemoveEventHandlers(True) Throw New System.NotImplementedException End Try Else Throw New System.NotImplementedException End If End Sub

 

Regards,

 

Romuald

 

1 REPLY

Re: Handle OnFileSaveAsUI and cancel save

Solution Partner Valued Contributor Solution Partner Valued Contributor
Solution Partner Valued Contributor

Hi community,

 

For those who have the same question, here is the solution I come up with :

 

 

        If Public_Vars.CustomFilename <> "" Then
            AddOrRemoveEventHandlers(False)

            Dim linksUpdateOption As SolidEdgeFramework.LinksUpdateOption
            Dim selectedfilter As Integer
            Dim strSaveAsFileName As String
            linksUpdateOption = SolidEdgeFramework.LinksUpdateOption.igNoLinksUpdate
            Try
                strSaveAsFileName = MyAddIn.Instance.Application.GetSaveAsFileName(linksUpdateOption, selectedfilter, InitialFilename:=Public_Vars.CustomFilename, FileFilter:="default")
            Catch ex As Exception
                Public_Vars.CustomFilename = ""
                AddOrRemoveEventHandlers(True)
                Throw New System.NotImplementedException
            End Try

            If Not strSaveAsFileName = "False" Then
                Filename = strSaveAsFileName
                Public_Vars.CustomFilename = ""
                AddOrRemoveEventHandlers(True)
            Else
                Public_Vars.CustomFilename = ""
                Filename = Nothing
                AppendToTitle = Nothing
                AddOrRemoveEventHandlers(True)
                Throw New System.Runtime.InteropServices.COMException(String.Empty, 1)
            End If

        Else
            Throw New System.NotImplementedException
        End If

 

Regards,

 

Romuald