4 Replies Latest reply on Apr 11, 2016 9:58 PM by Greg Rupp

    epdm API: when files NOT cached, calling openfiledialog from excel VSTO does not auto cache clicked file...

    Barry Cavanaugh

      Hello,

       

      I have created an excel vsto custom addin - this addin features a button that, when clicked, opens a openfiledialog browse window so that a user can select the solidworks files that they wish to attach to the excel file that is currently open.

       

      In situations where the selected cad files are already cached, everything works great.

       

      In situations where the cad files are NOT cached, the user can select the files and click OK to close the openfiledialog window, but an error occurs (file not found). Presumably this is because the file is not cached (therefore, to really present on the local computer)

       

      I wrote a simpler test program that is not called from the excel addin and in this case the openfiledialog window will auto cache the selected file upon being single-clicked by the user  - this is the desired behavior. It seems that the fact that I am calling openfiledialog from within my excel addin is preventing the auto cache behavior from occuring.

       

      I do have a workaround, although it is a bit extreme - for the openfiledialog portion of the addin I actually created a separate .exe that is called from the excel addin as a process - the openfiledialog window generated by this separate .exe DOES auto cache and everything works fine.

       

      anyone experienced anything like this before?

       

      Thanks for your thoughts on this.

       

      Barry

        • Re: epdm API: when files NOT cached, calling openfiledialog from excel VSTO does not auto cache clicked file...
          Tim Webb

          Hey Barry,

           

          Hope you get this working. Sounds really neat!

           

          Yeah, instead of using the OpenFileDialog that can't see the uncached files, use the BrowseForFile Method (IEdmVault5), it won't let you down. The code below makes the assumption you have already gotten the vault object and you have somehow already logged in the user which are shown below as <yourvaultobject>. I've also included a line <insert your code here to add the current file to the reference list> which is the "file" object just retrieved.

           

          'Let the user select multiple files
          Dim PathList As IEdmStrLst5
          PathList = <yourvaultobject>.BrowseForFile(0, EdmBrowseFlag.EdmBws_ForOpen + EdmBrowseFlag.EdmBws_PermitMultipleSel + EdmBrowseFlag.EdmBws_PermitVaultFiles, "All Files (*.*)|*.*||", "", "", "", "Select File...")
          
          'If the user didn't press Cancel... 
          If Not PathList Is Nothing Then
                'Spin through all the files and do something
                Dim pos As IEdmPos5 = Nothing
                Dim file As IEdmFile5 = Nothing
                pos = PathList.GetHeadPosition
                While Not pos.IsNull
                    file = <yourvaultobject>.GetFileFromPath(PathList.GetNext(pos), 0)
                   <insert your code here to add the current file to the reference list>
                End While
          End If
          
          

           

          You will need to figure out how to get the vault object on your own, using your codebase you already have.

          Good luck!

           

          Hope this helps,

          Tim CEPA

          http://www.equivaq.com

            • Re: epdm API: when files NOT cached, calling openfiledialog from excel VSTO does not auto cache clicked file...
              Barry Cavanaugh

              Thanks again for the suggestion. I implemented BrowseForFile from within my excel VSTO code, however it remains the case that even for this methodology the auto caching of "single-clicked" files in the file browser dialog does not trigger as desired.

               

              From within my excel vsto vb.net code I do instantiate an iedmvault5 object, log in OK and can browse and select files, but the "auto cache upon single click" behavior is not taking place. When I write the same code it its own executable, it auto caches as desired.

               

              my workaround is to create a separate openfiledialog.exe that is called by the vsto code via the process keyword - in this case, the code running the openfiledialog object is NOT directly tied to the excel vsto code and therefore does perform the auto caching...

               

              thanks again

               

              Barry

                • Re: epdm API: when files NOT cached, calling openfiledialog from excel VSTO does not auto cache clicked file...
                  Tim Webb

                  Could you use GetFileCopy to force a "Get" operation? You can then "Get" the file to any folder, not just within PDM.

                   

                  'Get the interface to the file and its parent folder 
                              Dim file As IEdmFile5
                              Dim folder As IEdmFolder5 = Nothing
                              file = vault.GetFileFromPath(filePath, folder)
                  
                              If file Is Nothing Then
                                  MessageBox.Show("The file is not in the vault " + VaultName + ".")
                              Else
                                  'Check out the file 
                                  file.LockFile(folder.ID, Me.Handle.ToInt32())
                                  MessageBox.Show("Checked out " & file.Name & " in vault " + VaultName + ".")
                  
                                  'Copy the file
                                  Dim verEnum As IEdmEnumeratorVersion5
                                  verEnum = file
                                  Dim Version As Integer
                                  Version = file.GetLocalVersionNo(folder.ID)
                                  Dim ver As IEdmVersion5
                                  ver = verEnum.GetVersion(Version)
                                  ver.GetFileCopy(Me.Handle.ToInt32(), "c:\temp\")
                                  MessageBox.Show("Copied " & file.Name & " to c:\temp.")
                               End If
                  
              • Re: epdm API: when files NOT cached, calling openfiledialog from excel VSTO does not auto cache clicked file...
                Greg Rupp

                Hi Barry,

                I had the same issue a few years back, but my issue was the opposite. The "auto-cache" feature you want, I believe is actually a bug. The only time a dialog window should actually download the file is if it's trying to generate a preview or it's told to get version/latest. The OpenFileDialog is the culprit... you may want to create your own opendialogbox function to create the desired response.

                 

                Please help - OpenFileDialog selection triggers EPDM Get Latest

                 

                SPR's

                594331 / 816512 / 925218 / 927445

                 

                Turns out there are lots of caching issues when using file dialog boxes...