ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

[µo°Ý] VBA½Ð¯q¦p¦ó¿ï¨ú¦hÀÉ«á¤W¶Ç¦Ü¥ØªºÀÉ

[µo°Ý] VBA½Ð¯q¦p¦ó¿ï¨ú¦hÀÉ«á¤W¶Ç¦Ü¥ØªºÀÉ

Dear ALL ¤j¤j:
1.¦p¹Ï¤@¥Ø«e¥i¥H¿ï¨ú³æ¤@Àɮצ¨¥\¤W¶Ç,
2.¦ý¬O§ï¦¨¦hÀÉ«á¤W¶Ç·|¨S¦³°Ê§@,
2.1¥Ø«e³æÀɿ鈴¼gªk:
      source = Application.GetOpenFilename
2.2¥Ø«e¦hÀÉ¿ï¨ú¼gªk:
      'source = Application.GetOpenFilename(MultiSelect:=True)
3.½Ð±Ð¦p¦ó­×§ï¬°¦hÀÉ«á¤W¶Ç¦Ü¥ØªºÀÉ.·Ð¤£§[½ç±Ð. THANKS

¹Ï¤@
Sub test()
Dim folder As String '¸ê®Æ
Dim source As String '¨Ó·½ÀÉ
Dim dest As String '¥ØªºÀÉ
Dim p As Integer
Dim s As Integer
Dim i As Long

folder = "D:\ABC" '¦s¨ú¥Øªº¦ì¸m

source = Application.GetOpenFilename '¨Ó·½

If source = "False" Then: MsgBox "¤W¶Ç¥¢±Ñ¡A½Ð¿ï¨ú¥¿½T¨Ó·½ÀɮסC": Exit Sub

p = 1
i = 1
Do Until p = 0
p = InStr(i, source, "\", 1)
If p = 0 Then Exit Do
s = p
i = p + 1
Loop

dest = folder & Mid(source, s, Len(source))

If Dir(dest) <> "" Then
MsgBox msg1
Else
FileCopy source, dest
MsgBox source & " ¤w¤W¶Ç¡C"
End If
Exit Sub
End Sub
ù

¦^´_ 1# rouber590324

°Ñ¦Ò¬Ý¬Ý
  1. Sub test()
  2. Dim folder As String '¸ê®Æ
  3. Dim source ' As String '¨Ó·½ÀÉ
  4. Dim source2, source3, source4 As String
  5. Dim dest As String '¥ØªºÀÉ
  6. Dim p As Integer
  7. Dim s As Integer
  8. Dim i As Long

  9. folder = "D:\ABC" '¦s¨ú¥Øªº¦ì¸m

  10. source = Application.GetOpenFilename(MultiSelect:=True)  '¨Ó·½

  11. If Not IsArray(source) Then: MsgBox "¤W¶Ç¥¢±Ñ¡A½Ð¿ï¨ú¥¿½T¨Ó·½ÀɮסC": Exit Sub

  12. For Each source2 In source
  13.     source3 = Split(source2, "\")
  14.     source4 = source3(UBound(source3))
  15.         
  16.     dest = IIf(Right(folder, 1) = "\", folder, folder & "\") & source4
  17.    
  18.     If Dir(dest) <> "" Then
  19.     MsgBox msg1
  20.     Else
  21.     FileCopy source2, dest
  22.     MsgBox source2 & " ¤w¤W¶Ç¡C"
  23.     End If
  24. Next
  25. End Sub
½Æ»s¥N½X

TOP

DEAR naruto018  ¤j¤j
·PÁ¸Ѵb  THANKS*10000
ù

TOP

        ÀR«ä¦Û¦b : ¤H¨ÆªºÁ}Ãø»PµZ¿i¡A´N¬O¤@ºØ¦ÒÅç¡C
ªð¦^¦Cªí ¤W¤@¥DÃD