Skip i'r prif gynnwys

Sut i fewnforio enwau ffeiliau lluosog i mewn i gelloedd yn Excel?

Awdur: Xiaoyang Wedi'i Addasu Diwethaf: 2020-05-27

Gan dybio bod gennych ffolder gyda channoedd o ffeiliau, ac yn awr, rydych chi am fewnforio'r enwau ffeiliau hyn i mewn i gelloedd taflen waith. Bydd copïo a gludo fesul un yn treulio llawer o amser, yn yr erthygl hon, byddaf yn siarad am rai triciau cyflym i'ch helpu chi i fewnforio enwau ffeiliau lluosog o ffolder i mewn i daflen waith.

Mewnforio enwau ffeiliau lluosog i mewn i gelloedd taflen waith gyda chod VBA

Mewnforio enwau ffeiliau lluosog i mewn i gelloedd taflen waith gyda Kutools ar gyfer Excel


Mewnforio enwau ffeiliau lluosog i mewn i gelloedd taflen waith gyda chod VBA

Gall y cod VBA canlynol eich helpu i fewnforio enwau ffeiliau, estyniadau ffeiliau ac enw'r ffolder i mewn i'r celloedd taflen waith, gwnewch y camau canlynol:

1. Lansio taflen waith newydd rydych chi am fewnforio enwau'r ffeiliau.

2. Daliwch i lawr y ALT + F11 allweddi i agor y Microsoft Visual Basic ar gyfer Ceisiadau ffenestr.

3. Cliciwch Mewnosod > Modiwlau, a gludwch y cod canlynol yn y Modiwlau Ffenestr.

Cod VBA: Mewnforio enwau ffeiliau lluosog i mewn i gelloedd taflen waith

Sub GetFileList()
'updateby Extendoffice
    Dim xFSO As Object
    Dim xFolder As Object
    Dim xFile As Object
    Dim xFiDialog As FileDialog
    Dim xPath As String
    Dim i As Integer
    Set xFiDialog = Application.FileDialog(msoFileDialogFolderPicker)
    If xFiDialog.Show = -1 Then
        xPath = xFiDialog.SelectedItems(1)
    End If
    Set xFiDialog = Nothing
    If xPath = "" Then Exit Sub
    Set xFSO = CreateObject("Scripting.FileSystemObject")
    Set xFolder = xFSO.GetFolder(xPath)
    ActiveSheet.Cells(1, 1) = "Folder name"
    ActiveSheet.Cells(1, 2) = "File name"
    ActiveSheet.Cells(1, 3) = "File extension"
    i = 1
    For Each xFile In xFolder.Files
        i = i + 1
        ActiveSheet.Cells(i, 1) = xPath
        ActiveSheet.Cells(i, 2) = Left(xFile.Name, InStrRev(xFile.Name, ".") - 1)
        ActiveSheet.Cells(i, 3) = Mid(xFile.Name, InStrRev(xFile.Name, ".") + 1)
    Next
End Sub

4. Yna, pwyswch F5 allwedd i weithredu'r cod hwn, ac yn y ffenestr Pori allan, dewiswch y ffolder rydych chi am fewnforio'r ffurflen enwau ffeiliau, gweler y screenshot:

doc mewnforio enwau ffeiliau 1

5. Ac yna cliciwch OK botwm, a chewch y canlyniad canlynol:

doc mewnforio enwau ffeiliau 2

Nodyn: Os oes is-ffolderi yn eich ffolder benodol, ni fydd enwau'r ffeiliau yn yr is-ffolderi yn cael eu mewnforio.


Mewnforio enwau ffeiliau lluosog i mewn i gelloedd taflen waith gyda Kutools ar gyfer Excel

Os oes angen i chi fewnforio enwau'r ffeiliau yn y ffolder a'r is-ffolderi, peidiwch â phoeni, gyda Kutools ar gyfer Excel'S Rhestr Enw Ffeil cyfleustodau, gallwch chi fewnforio'r holl enwau ffeiliau yn hawdd yn y ffolder benodol gan gynnwys yr is-ffolderi.

Kutools ar gyfer Excel : gyda mwy na 300 o ychwanegiadau Excel defnyddiol, am ddim i geisio heb unrhyw gyfyngiad mewn 30 diwrnod. 

Ar ôl gosod Kutools ar gyfer Excel, gwnewch fel a ganlyn:

1. Cliciwch Kutools Byd Gwaith> Mewnforio ac Allforio > Rhestr Enw Ffeil, gweler y screenshot:

2. Yn y Rhestr Enw Ffeil blwch deialog, gwnewch y gweithrediadau canlynol:

(1.) Cliciwch doc mewnforio enwau ffeiliau 5 botwm i ddewis y ffolder gyda'r ffeiliau rydych chi am eu mewnforio;

(2.) Gwiriwch Cynhwyswch ffeiliau mewn is-gyfeiriaduron mewnforio enwau ffeiliau'r is-ffolderi;

(3.) Nodwch y math o ffeiliau rydych chi am eu mewnforio o dan y Math o ffeiliau adran;

(4.) Dewiswch un uned maint ffeil rydych chi am ei harddangos o'r Uned maint ffeil adran;

(5.) Os ydych chi eisiau hypergysylltu'r enwau ffeiliau a'r ffolderau, gwiriwch Creu hypergysylltiadau opsiwn.

doc mewnforio enwau ffeiliau 4

3. Ar ôl gorffen y gosodiadau, cliciwch OK botwm, ac mae'r enwau ffeiliau mewn ffolder ac is-ffolderi yn cael eu mewnforio i daflen waith newydd fel y dangosir y llun a ganlyn:

doc mewnforio enwau ffeiliau 6

Awgrymiadau: Os ydych chi am fewnforio un enw ffeil math penodedig yn unig o ffolder benodol, gallwch wirio Nodwch opsiwn yn y Rhestr Enw Ffeil deialog, a theipiwch yr estyniad ffeil ynddo, yna dim ond o'r ffolder a'r is-ffolderi y bydd yn mewnforio'r enwau ffeiliau math penodedig yn unig.

Cliciwch i wybod mwy am y nodwedd Rhestr Enw Ffeil hon ...

Dadlwythwch a threial am ddim Kutools ar gyfer Excel Nawr !


Demo: Mewnforio enwau ffeiliau lluosog i mewn i gelloedd taflen waith gyda Kutools ar gyfer Excel

Kutools ar gyfer Excel: gyda mwy na 300 o ychwanegiadau Excel defnyddiol, am ddim i geisio heb unrhyw gyfyngiad mewn 30 diwrnod. Dadlwythwch a threial am ddim Nawr!

Erthyglau cysylltiedig:

Sut i restru'r holl ffeiliau mewn ffolder ac is-ffolderi i mewn i daflen waith?

Sut i restru'r holl enwau ffeiliau mewn ffolder a chreu hypergysylltiadau ar eu cyfer yn Excel?

Offer Cynhyrchiant Swyddfa Gorau

🤖 Kutools AI Aide: Chwyldro dadansoddi data yn seiliedig ar: Cyflawniad Deallus   |  Cynhyrchu Cod  |  Creu Fformiwlâu Personol  |  Dadansoddi Data a Chynhyrchu Siartiau  |  Invoke Swyddogaethau Kutools...
Nodweddion Poblogaidd: Darganfod, Amlygu neu Adnabod Dyblygiadau   |  Dileu Rhesi Gwag   |  Cyfuno Colofnau neu Gelloedd heb Colli Data   |   Rownd heb Fformiwla ...
Super-edrych: VLookup Meini Prawf Lluosog    VLookup Gwerth Lluosog  |   VLookup Ar Draws Taflenni Lluosog   |   Edrych Niwlog ....
Rhestr gwympo Uwch: Creu Rhestr Gollwng yn Gyflym   |  Rhestr Gollwng Dibynnol   |  Rhestr Gollwng Aml-ddewis ....
Rheolwr Colofn: Ychwanegu Nifer Penodol o Golofnau  |  Symud Colofnau  |  Toglo Statws Gwelededd Colofnau Cudd  |  Cymharwch Ystodau a Cholofnau ...
Nodweddion dan Sylw: Ffocws ar y Grid   |  Golwg Dylunio   |   Bar Fformiwla Mawr    Rheolwr Llyfr Gwaith a Thaflen   |  Llyfrgell Adnoddau (Testun Auto)   |  Dewiswr Dyddiad   |  Cyfuno Taflenni Gwaith   |  Amgryptio/Dadgryptio Celloedd    Anfon E-byst trwy Restr   |  Hidlo Super   |   Hidlo Arbennig (hidlo mewn print trwm/italig/strikethrough...) ...
15 Set Offer Gorau12 Testun offer (Ychwanegu Testun, Dileu Cymeriadau,...)   |   50 + Siart Mathau (Siart Gantt,...)   |   40+ Ymarferol Fformiwlâu (Cyfrifwch oedran yn seiliedig ar ben-blwydd,...)   |   19 mewnosod offer (Mewnosod Cod QR, Mewnosod Llun o'r Llwybr,...)   |   12 Trosi offer (Rhifau i Eiriau, Trosi arian cyfred,...)   |   7 Uno a Hollti offer (Rhesi Cyfuno Uwch, Celloedd Hollt,...)   |   ... a mwy

Supercharge Eich Sgiliau Excel gyda Kutools ar gyfer Excel, a Phrofiad Effeithlonrwydd Fel Erioed Erioed. Kutools ar gyfer Excel Yn Cynnig Dros 300 o Nodweddion Uwch i Hybu Cynhyrchiant ac Arbed Amser.  Cliciwch Yma i Gael Y Nodwedd Sydd Ei Angen Y Mwyaf...

Disgrifiad


Mae Office Tab yn dod â rhyngwyneb Tabbed i Office, ac yn Gwneud Eich Gwaith yn Haws o lawer

  • Galluogi golygu a darllen tabbed yn Word, Excel, PowerPoint, Cyhoeddwr, Mynediad, Visio a Phrosiect.
  • Agor a chreu dogfennau lluosog mewn tabiau newydd o'r un ffenestr, yn hytrach nag mewn ffenestri newydd.
  • Yn cynyddu eich cynhyrchiant 50%, ac yn lleihau cannoedd o gliciau llygoden i chi bob dydd!
Comments (14)
Rated 5 out of 5 · 1 ratings
This comment was minimized by the moderator on the site
very helpful. Tnx much
Rated 5 out of 5
This comment was minimized by the moderator on the site
Another easy method is there. Just copy the directory path where you have saved the documents, and paste that link in browser (chrome/mozilla). You will get the name list and just copy paste into excel. Cheers!
This comment was minimized by the moderator on the site
i want to add table,only folder name,and data modified as well?
This comment was minimized by the moderator on the site
Hello,
Do you want to list all folder names from a specific main folder? Please give your problem more detailed.
This comment was minimized by the moderator on the site
i want to mention only folder name.what is vba code for that.
This comment was minimized by the moderator on the site
is there a way to put the folder path already in the code?
This comment was minimized by the moderator on the site
For the VBA code, how would you pull in the date modified as well?
This comment was minimized by the moderator on the site
Hello,
Add the date modified column for the imported filenames, please apply the following VBA code, please try it, hope it can help you!

Sub GetFileList()
Dim xFSO As Object
Dim xFolder As Object
Dim xFile As Object
Dim xFiDialog As FileDialog
Dim xPath As String
Dim i As Integer
Set xFiDialog = Application.FileDialog(msoFileDialogFolderPicker)
If xFiDialog.Show = -1 Then
xPath = xFiDialog.SelectedItems(1)
End If
Set xFiDialog = Nothing
If xPath = "" Then Exit Sub
Set xFSO = CreateObject("Scripting.FileSystemObject")
Set xFolder = xFSO.GetFolder(xPath)
ActiveSheet.Cells(1, 1) = "Folder name"
ActiveSheet.Cells(1, 2) = "File name"
ActiveSheet.Cells(1, 3) = "File extension"
ActiveSheet.Cells(1, 4) = "Date last modified"
i = 1
For Each xFile In xFolder.Files
i = i + 1
ActiveSheet.Cells(i, 1) = xPath
ActiveSheet.Cells(i, 2) = Left(xFile.Name, InStrRev(xFile.Name, ".") - 1)
ActiveSheet.Cells(i, 3) = Mid(xFile.Name, InStrRev(xFile.Name, ".") + 1)
ActiveSheet.Cells(i, 4) = CDate(xFile.datelastmodified)
Next
End Sub
This comment was minimized by the moderator on the site
Thanks. It was awesome
This comment was minimized by the moderator on the site
saya coba yg pake vba di run bisa tapi pas di step browser nya bukan oke tapi open terus sampai ke file tertentu dan ketika di klik malah run time 26 path not found bisa bantu kenapa itu bisa terjadi?
This comment was minimized by the moderator on the site
Apakah bisa merename file dengan excel?
terimakasih sangat membantu perkerjaan saya,
This comment was minimized by the moderator on the site
Very helpful, thank you!
There are no comments posted here yet
Load More
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations