ciao NebbiaDb,
non capisco...
nel senso che la modifica del nome del file deve essere eseguite tramita la procedure dell'evento click del post precedente.
Se modifichi il nome del file prima di lanciare la procedura dell'evento click di cui al precedente post, il file per forza il file non esiste ed esce il messaggio.
ciao, Sandro.
*** edit ***
forse ho capito...
modifica questo :
Private Sub txtNuovoNomeFile_AfterUpdate()
Me.txtNuovoNomeFile = Me.txtNuovoNomeFile & justExtention
Me.txtFile = Me.txtNuovoNomeFile
End Sub
e questo :
Private Sub cmdCopyFiles3_Click()
On Error GoTo errorHandler
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
Dim strFile As String
strFile = Me.txtFile
If Not FileExists(strFile) Then VBA.MsgBox "il file non esiste", vbCritical, "warning": Exit Sub
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
Dim strFileName As String
strFileName = myPath & Me.txtCategoria & "" & Me.txtSottocategoria & "" & strFile
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
strFile = strFile & justExtention
Loop
End If
End If
Me.txtNuovoNomeFile = IIf(Len(strFile & vbNullString) = 0, Me.txtFile, strFile)
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"
ext_errorLoadAccountHandler:
Exit Sub
errorHandler:
With Err
MsgBox "ERR#" & .Number _
& vbNewLine & .Description _
, vbOKOnly Or vbCritical
End With
Resume ext_errorLoadAccountHandler
End Sub
*** end edit ***