snasui.com ยินดีต้อนรับ ยินดีต้อนรับสู่กระดานถามตอบ Excel and VBA และอื่น ๆ ที่เป็นมิตรกับทุกท่าน มีไฟล์แนบมหาศาล ช่วยให้ท่านค้นหาและติดตามศึกษาได้โดยง่าย สมาชิกท่านใดที่ยังไม่ได้ระบุ Version ของ Excel ที่ใช้งานจริง สามารถทำตาม Link นี้เพื่อจะได้รับคำตอบที่ตรงกับ Version ของท่านครับ ระบุ Version ของ Excel
Private Sub CommandButton1_Click()
Dim str1 As String
Dim str2 As String
Dim mypath As String
Dim strFileExists As String
Dim filenames As String
mypath = ThisWorkbook.path & "\"
filenames = Range("G7")
str1 = mypath & filenames & ".xlsm"
str2 = mypath & txt1.Value & "-" & txt2.Value & "-" & txt3.Value & ".xlsm"
strFileExists = Dir(str2)
If strFileExists = "" Then
FileCopy str1, str2
MsgBox "สร้างไฟล์สำเร็จ"
Else
MsgBox "ไฟล์นี้น่าจะอยู่แล้วกรุณาตรวจสอบใหม่อีกครั้ง"
End If
End Sub
You do not have the required permissions to view the files attached to this post.