ciao NebbiaDB,
prova a sostituire la routine evento click del command button cmdCopyFiles3 in questo modo :
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.txtNuovoNomeFile) Then VBA.MsgBox "il file non esiste", vbCritical, "warning": Exit Sub
Dim strFile As String
Dim i As Integer
Dim strFileName As String
'strFile = justFileName(Me.txtNuovoNomeFile)
strFile = myPath & Me.txtCategoria & "" & Me.txtNuovoNomeFile
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
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"
strInfo2 = "il file:" & vbNewLine & _
strFileName & vbNewLine & _
"già esiste."
Title = "Warning!"
style = vbCritical + vbOKCancel
style2 = vbCritical
If FileExists(strFileName) Then
If VBA.MsgBox(strInfo, style, Title) = vbOK Then
justExtention = justExtentionFileName(Me.txtPath & Me.txtFile)
Do While Len(Dir(strFileName)) > 0
strFileName = InputBox("nome del file:", "Inserisci il nome del file", , 12000, 7000)
strFileName = myPath & Me.txtCategoria & "" & Me.txtSottocategoria & "" & strFileName & justExtention
If FileExists(strFileName) Then VBA.MsgBox strInfo2, style2, Title
Loop
End If
End If
strFile = strFileName
FileCopy Me.txtNuovoNomeFile, strFileName
If FileExists(strFileName) Then VBA.MsgBox "file copiato con successo", vbInformation, "Info"
end sub
ciao, Sandro.