4 Replies Latest reply on Nov 10, 2014 10:44 AM by Lee CS Young

    new folder excel vba

    Enrico Camusso

      Good morning.

      I'm sorry for my bad English.

       

      I have a problem, I write a new macro in excel and I need that when i save the file automaticly they create a new folder in the EPDM.

      If the folder already exist we haven't a problem and the macro can save the file , but I not understad when I can make the new folder. I don't know the istruction for the EPDM to use in excel VBA.

      Please Help me

      Thanks

        • Re: new folder excel vba
          Lee CS Young

          Here's a quick example to get you started. It will check for the existence of a file and if it doesn't exist it will create it. Note that it creates the folder relative to the vault root.

           

          Dim Vault As Object
          Sub LoginToVault()
              Set Vault = CreateObject("ConisioLib.EdmVault")
              Vault.LoginAuto "Sandbox", 0
          End Sub
          ' Check if the folder exists.
          Function VaultFolderExists(folderPath) As Boolean
              Dim Folder As IEdmFolder5
              Set Folder = Vault.GetFolderFromPath(folderPath)
              If Not Folder Is Nothing Then
                  VaultFolderExists = True
              Else
                  VaultFolderExists = False
              End If
          End Function
          ' Create the folder relative to the vault root.
          Sub CreateFolder(folderPath)
              Call LoginToVault
              If Not VaultFolderExists(folderPath) Then
                  Dim CreatedFolder As IEdmFolder5
                  Set CreatedFolder = Vault.RootFolder.CreateFolderPath(folderPath, 0)
              End If
          End Sub
          ' Try creating a folder. Note that the vault root is not specified.
          Sub TryIt()
              CreateFolder "\AddedFolder\Test"
          End Sub
          
            • Re: new folder excel vba
              Enrico Camusso

              Thanks for all

               

              I try your code ASAP

               

              thanks

               

              Hi, I've tried your code, but i' ve a problem , when the code try to create a new folder in the root they send a message that I haven't the permissions for this operation, because the normal user can't make a new folder in the root.

              In reason of my code must be used for all my colleagues I need , if is possible to create the new folder not in the root.

               

               

              We have this structure of the EPDM \Inpeco\Project\Development G7.... I need to create in this path my new folder.

               

               

              this is possible?  How I can modify your code to obtain this results?

               

               

              Thanks

              • Re: new folder excel vba
                Enrico Camusso

                I' ve tried to modify your code to make a subdirectory but I don't know very well VBA and I have a problem for this

                We have this structure of the EPDM \Inpeco\Project\Development G7.... I need to create in this path my new folder.

                 

                this is possible?  How I can modify your code to obtain this results?

                 

                Thanks

                  • Re: new folder excel vba
                    Lee CS Young

                    You can do something like this;

                     

                    Sub CreateFolder(folderPath)  
                        Call LoginToVault  
                        If Not VaultFolderExists(folderPath) Then  
                      Dim RootFolder as IEdmFolder5
                      Dim CreatedFolder As IEdmFolder5  
                      Set RootFolder = Vault.GetFolderFromPath("\Inpeco\Project\Development G7") ' set whatever path you want here        
                      If Not RootFolder Is Nothing Then
                      Set CreatedFolder = RootFolder.CreateFolderPath(folderPath, 0)  
                      End If
                        End If  
                    End Sub