Skip to main content

AccessTr.neT


Excel Dosyasını İsim Değiştirerek Kaydetmek

Excel Dosyasını İsim Değiştirerek Kaydetmek

#1
Kod:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)

    Dim sOldName As String

    'If SaveAsUI Then
        Cancel = True 'cancel the save and do it yourself in code
        sOldName = Me.FullName 'store the old name so you can delete it later

        'Save using the value in the cell
        Application.EnableEvents = False
            Me.SaveAs Me.Path & Application.PathSeparator & _
                Me.Worksheets("CUST").Range("FILE").Value & ".xls"
        Application.EnableEvents = True

        'If the name changed, delete the old file
        If Me.FullName <> sOldName Then
            On Error Resume Next
                Kill sOldName
            On Error GoTo 0
        End If

    'End If

End Sub

@benbendedeilem
Cevapla

Bir hesap oluşturun veya yorum yapmak için giriş yapın

Yorum yapmak için üye olmanız gerekiyor

ya da
Task