اذهب الي المحتوي
أوفيسنا

تعديل على كود حفظ باسم


الردود الموصى بها

 التعديل على الكود بحيث يبقي الملف الاساسي مفتوح وغلق تلقائي للنسخه المستحدثة الملف مرفق مع الشرح وهذه نسخه عن الكود

Private Sub Worksheet_Change(ByVal Target As Range)
Dim lr As String
 Dim Destwb As Workbook
Dim path As String

path = "D:\hhh\"
If Target.Column = 3 Then
lr = Sheets(1).Range("c" & Rows.Count).End(xlUp).Rows.Value

End If
With Application
        .ScreenUpdating = False
        .EnableEvents = False
    End With

  Set Destwb = ActiveWorkbook
 
With Destwb

  .SaveAs Filename:=path & lr, FileFormat:=52
        .Close SaveChanges:=False
    End With
    MsgBox "You can find the new file in " & lr
     With Application
        .ScreenUpdating = True
        .EnableEvents = True
    End With
   
   
   
End Sub

نرجو من الاساتذه المشاركه مع خالص تحياتي

رابط هذا التعليق
شارك

السلام عليكم

جرب الكود المعدل التالي:

Private Sub Worksheet_Change(ByVal Target As Range)
Dim lr As String
Dim Destwb As Workbook, Source
Dim path As String

Source = ThisWorkbook.FullName

path = "D:\hhh\"

If Target.Column = 3 Then
  lr = Sheets(1).Range("c" & Rows.Count).End(xlUp).Rows.Value
End If

With Application
   .ScreenUpdating = False
   .EnableEvents = False
End With

Set Destwb = ActiveWorkbook
 
With Destwb
  .SaveAs Filename:=path & lr, FileFormat:=52
End With

Workbooks.Open Source
 
MsgBox "You can find the new file in " & lr

Destwb.Close

With Application
   .ScreenUpdating = True
   .EnableEvents = True
End With

End Sub

بن علية حاجي

  • Like 1
رابط هذا التعليق
شارك

شكرا جزيلا اخي بن علية حاجي على النظر في امري ولكنه اولاً لا يحفظ المتغيرات في الملف الأساسي ثانياً عند وجود اكواد أخرى في مودل وفورم  لا يعمل الكود ابداً ارجو االنظر وشكرا على الاهتمام مره اخرى

رابط هذا التعليق
شارك

شكرا لكم لقد حلت واللحمدلله

Private Sub Worksheet_Change(ByVal Target As Range)

Dim lr As String
Dim Destwb As Workbook, Source
Dim path As String
ThisWorkbook.Save
Source = ThisWorkbook.FullName

path = "D:\hhh\"

If Target.Column = 3 Then
  lr = Sheets(1).Range("c" & Rows.Count).End(xlUp).Rows.Value
End If

With Application
   .ScreenUpdating = False
   .EnableEvents = False
End With

Set Destwb = ActiveWorkbook
 
With Destwb
  .SaveAs Filename:=path & lr, FileFormat:=52
End With

Workbooks.Open Source
 
MsgBox "You can find the new file in " & lr

Destwb.Close

With Application
   .ScreenUpdating = True
   .EnableEvents = True
End With
End Sub

رابط هذا التعليق
شارك

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

زائر
اضف رد علي هذا الموضوع....

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • اضف...

Important Information