Ciao Sandro
scusami tanto se mi sono persone
questo il mio codice e succede questo:
carico il file e se clicco si su modifica nome file (sandro.txt) il cursore si posiziona su txtNuovoNomeFile e scrivo (nebbia);
su invio mi scrive nebbia.txt
Clicco su cmdCopyFiles3 e mi esce msg file non esiste.
in alto
Option Compare Database
Option Explicit
Dim justExtention As String
Dim bool As Boolean
Public Function justExtentionFileName(ByVal strFullPath As String) As String
justExtentionFileName = Mid$(strFullPath, InStrRev(strFullPath, "."), Len(strFullPath))
End Function
Private Sub cmdFile_Click()
'apre la finestra per scegliere il file
Dim lngSlashPos As Long
Dim fullPath As String
fullPath = cmdFileDialog
lngSlashPos = InStrRev(fullPath, "")
Me.txtPath = Mid$(fullPath, 1, lngSlashPos)
Me.txtFile = justFileName(fullPath)
Me.Recalc
Dim iRisposta As Integer
iRisposta = MsgBox("Vuoi modificare il nome del file ???", vbYesNoCancel)
Select Case iRisposta 'impostiamo il Select Case con riferimento al messaggio restituito dalla variabile iRisposta
Case vbYes 'se risponderemo "Si" :
Me.txtNuovoNomeFile.SetFocus
Me.txtNuovoNomeFile.BackColor = vbRed
Case vbNo 'se sceglieremo "No":
Me.txtNuovoNomeFile = Me.txtFile
Exit Sub
Case Else
End Select
End Sub
Private Sub txtNuovoNomeFile_BeforeUpdate(Cancel As Integer)
'prima di aggiornare il controllo Nuovo Nome File
justExtention = justExtentionFileName(Me.txtPath & Me.txtFile)
If bool Then
If FileExists(Me.txtPath & Me.txtNuovoNomeFile) Then
VBA.MsgBox Me.txtPath & Me.txtNuovoNomeFile & vbNewLine & _
" esiste già assegna un altro nome!", vbCritical, "Warning"
Cancel = True
Else
Name Me.txtPath & Me.txtFile As Me.txtPath & Me.txtNuovoNomeFile & justExtention
Me.txtNuovoNomeFile.BackColor = vbWhite
VBA.MsgBox "Ho rinominato :" & vbNewLine & _
Me.txtPath & Me.txtFile & vbNewLine & _
" così:" & vbNewLine & _
Me.txtPath & Me.txtNuovoNomeFile & justExtention, vbInformation
bool = False
End If
End If
End Sub
Private Sub txtNuovoNomeFile_Change()
'su modifica del controllo Nuovo Nome File
Me.txtNuovoNomeFile.BackColor = vbWhite
End Sub
Private Sub txtNuovoNomeFile_AfterUpdate()
'dopo aggiornamento del controllo Nuovo Nome File
Me.txtNuovoNomeFile = Me.txtNuovoNomeFile & justExtention
End Sub