• Create Windows Folder (v2000)

    Author
    Topic
    #395449

    I am trying to add code to a command button to create a Windows Folder from a combo box. For instance, if the combo box reads ‘NewFolder’, I want the on-click event to create folder C:NewFolder.

    The part where I am stuck is what code will actually create the folder.
    Thanks!

    Viewing 1 reply thread
    Author
    Replies
    • #733872

      Here’s one way that doesn’t require any special references or advanced coding.

      On Error Resume Next
      
      MkDir strDirName
      If Err = 75 Then        
          ' the folder exists already
      Else
          Err = 0
          ' try to create it again
          MkDir strDirName
          If Err = 75 Then
              ' the directory was created
          Else
              MsgBox "Error in Creating Folder: " & strDirName & ".",  _
                            vbExclamation, "Folder Create Failure"
          End If
      End If 
      • #733888

        Charlotte,
        That was a huge help and it worked like a charm. Thanks a bunch!!

    • #733873

      Here’s one way that doesn’t require any special references or advanced coding.

      On Error Resume Next
      
      MkDir strDirName
      If Err = 75 Then        
          ' the folder exists already
      Else
          Err = 0
          ' try to create it again
          MkDir strDirName
          If Err = 75 Then
              ' the directory was created
          Else
              MsgBox "Error in Creating Folder: " & strDirName & ".",  _
                            vbExclamation, "Folder Create Failure"
          End If
      End If 
    Viewing 1 reply thread
    Reply To: Create Windows Folder (v2000)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: