ciao NebbiaDB,
ok, prova a vedere se con queste modifiche ci siamo :
Private Sub cmdCopyFiles3_Click()
If Len(Me.txtCategoria & vbNullString) = 0 Then
VBA.MsgBox "Categoria MANCANTE!!!", vbCritical, "Attenzione"
Exit Sub
End If
If Len(Me.txtSottocategoria & vbNullString) = 0 Then
VBA.MsgBox "SottoCategoria MANCANTE!!!", vbCritical, "Attenzione"
Exit Sub
End If
Const myPath As String = "C:\reports" ' <----- personalizza il path!!
If Not folderExists(myPath) Then MkDir myPath
If Not FileExists(Me.txtFile) Then VBA.MsgBox "il file non esiste", vbCritical, "warning": Exit Sub
Dim strFile As String
Dim i As Integer
Dim strFileName As String
If Not folderExists(myPath & Me.txtCategoria) Then
MkDir myPath & Me.txtCategoria
End If
If Not folderExists(myPath & Me.txtCategoria & "" & Me.txtSottocategoria) Then
MkDir myPath & Me.txtCategoria & "" & Me.txtSottocategoria
End If
strFileName = myPath & Me.txtCategoria & "" & Me.txtSottocategoria & "" & Me.txtNuovoNomeFile
If FileExists(strFileName) Then
Dim style As VBA.VbMsgBoxStyle
Dim style2 As VBA.VbMsgBoxStyle
Dim strInfo As String
Dim strInfo2 As String
Dim Title As String
strInfo = "il file:" & vbNewLine & _
strFileName & vbNewLine & _
"già esiste." & vbNewLine & _
"ok per rinominare, annulla per sovrascrivere"
Title = "Warning!"
style = vbCritical + vbOKCancel
style2 = vbCritical
If VBA.MsgBox(strInfo, style, Title) = vbOK Then
justExtention = justExtentionFileName(Me.txtPath & Me.txtFile)
Do While Len(Dir(strFileName)) > 0
strFile = InputBox("nome del file:", "Inserisci il nome del file", , 12000, 7000)
strFileName = myPath & Me.txtCategoria & "" & Me.txtSottocategoria & "" & strFile & justExtention
If FileExists(strFileName) Then
strInfo2 = "il file:" & vbNewLine & _
strFileName & vbNewLine & _
"già esiste."
VBA.MsgBox strInfo2, style2, Title
End If
Loop
End If
End If
Me.txtNuovoNomeFile = IIf(Len(strFile & vbNullString) = 0, Me.txtFile, strFile & justExtention)
Me.txtNuovoPercorso = myPath & Me.txtCategoria & "" & Me.txtSottocategoria & ""
FileCopy Me.txtPath & Me.txtFile, strFileName
If FileExists(strFileName) Then VBA.MsgBox "file copiato con successo", vbInformation, "Info"
End Sub
ciao, Sandro.