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

[µo°Ý] ¨ú±o¥~³¡excelÀx¦s®æ¸ê®Æ¤º®eªº¤èªk

[µo°Ý] ¨ú±o¥~³¡excelÀx¦s®æ¸ê®Æ¤º®eªº¤èªk

§Ú¦bºô¤W«÷´ê¤F¤U­±ªº¥N½X¡ACells(i, 1)¤ÎCells(i, 2)¥i¥¿±`¦C¦L¡A
¥i¬O¦bCells(i, 3) = Workbooks(.SelectedItems(i)).Sheets("Sheet1").Range("A15").Value
µLªk¥¿±`Ū¨ú¦s¦ÜCells(i, 3) ¡A½Ð°Ý°ª¤â¬O¨º¸Ì¥X¿ù¤F
©ÎªÌ¨ä¥¦¿ëªk¨ú±o¡A

»s§@¥D­nªº­n¨D¬O¡G
1.¿ï¨ú¸ê®Æ§¨¤¤ªº*.xls©Î*.xlsx
2.¦C¦L©Ò¿ïªºxls¤¤ªºSheet1 Àx¦s®æ¡A¦@¬ù60®æ(¥þ³¡"¤å¦r®æ¦¡"ªí¥Ü(¦p¤é´Á¡B®É¶¡¡B¼Æ¦r)¡A¤]¦³ªÅ¥Õ®æ)¡A¥þ³¡¤£¬Û¾F¡A±N¨äÅܦ¨°}¦C¡A¦A¥H°}¦C¤è¦¡¦C¦L¦¨ 5¦C*12Äæ
  1. Sub Test()
  2. Columns("A:C").ClearContents
  3. With Application.FileDialog(msoFileDialogFilePicker)
  4.         .InitialFileName = "C:\Users\¨Ï¥ÎªÌ\Desktop\"           '«ü©wªì©l¸ô®|
  5.         .AllowMultiSelect = True                                '¶}±Ò½Æ¿ï¥\¯à
  6.         .Show
  7.         For i = 1 To .SelectedItems.Count
  8.             Cells(i, 1) = CreateObject("Scripting.FileSystemObject").GetParentFolderName(.SelectedItems(i)) & "\"          'Àɮ׸ô®|(§t¤é¤å)
  9.             Cells(i, 2) = CreateObject("Scripting.FileSystemObject").GetFileName(.SelectedItems(i))                      'ÀɮצWºÙ(§t¤é¤å)
  10.             
  11.             Cells(i, 3) = Workbooks(.SelectedItems(i)).Sheets("Sheet1").Range("A15").Value                         'µLªk¦¨¥\Ū¨ú
  12.             
  13.     'MsgBox CreateObject("Scripting.FileSystemObject").GetFileName(.SelectedItems(i))                        'ÀɮצWºÙ
  14.     'MsgBox CreateObject("Scripting.FileSystemObject").GetParentFolderName(.SelectedItems(i)) & "\"          'Àɮ׸ô®|    '(¦pªG¬O¥²»Ýªº¡A§A¥i¥H¦Û¤v¸É³Ì«áªº¡u\¡v)
  15.             
  16.         Next
  17.     End With
  18. End Sub
½Æ»s¥N½X
°¸¦Ó¾Ç²ß

¦^´_ 1# roy1221
  1. Option Explicit
  2. Sub Test()
  3.     Dim i As Integer
  4.     Columns("A:C").ClearContents
  5.     With Application.FileDialog(msoFileDialogFilePicker)
  6.         .InitialFileName = "C:\Users\¨Ï¥ÎªÌ\Desktop\"           '«ü©wªì©l¸ô®|
  7.         .AllowMultiSelect = True                                '¶}±Ò½Æ¿ï¥\¯à
  8.         .Show
  9.         For i = 1 To .SelectedItems.Count
  10.             Cells(i, 1) = CreateObject("Scripting.FileSystemObject").GetParentFolderName(.SelectedItems(i)) & "\"          'Àɮ׸ô®|(§t¤é¤å)
  11.             Cells(i, 2) = CreateObject("Scripting.FileSystemObject").GetFileName(.SelectedItems(i))
  12.             Cells(i, 3) = CreateObject(.SelectedItems(i)).Sheets("Sheet1").Range("A15").Value                         '
  13.             CreateObject(.SelectedItems(i)).Close        '** Ãö³¬ÀÉ®×
  14.             'MsgBox CreateObject("Scripting.FileSystemObject").GetFileName(.SelectedItems(i))                        'ÀɮצWºÙ
  15.             'MsgBox CreateObject("Scripting.FileSystemObject").GetParentFolderName(.SelectedItems(i)) & "\"          'Àɮ׸ô®|    '(¦pªG¬O¥²»Ýªº¡A§A¥i¥H¦Û¤v¸É³Ì«áªº¡u\¡v)
  16.         Next
  17.     End With
  18. End Sub
½Æ»s¥N½X

TOP

ÁÂÁ¡A¤w¸g§¹¦¨©Ò­nªº©Ò¦³¥\¯à¤F
°¸¦Ó¾Ç²ß

TOP

        ÀR«ä¦Û¦b : ¥¬¬I¦p¼½ºØ¡A¥HÅw³ß¤ß´þ¼íºØ¤l¡A¤~·|µoªÞ¡C
ªð¦^¦Cªí ¤W¤@¥DÃD