VBA Macro Code - Copy Data from Multiple Word Files to Excel

Поділитися
Вставка
  • Опубліковано 16 жов 2024
  • In this video, you will learn how you can Copy Data from Multiple Word Files to Excel using VBA Macro Code.
    VBA Macro Code Used in the video:
    Sub Copy_Data_From_Multiple_WordFiles()
    Dim FolderName As String
    Dim FileName As String
    Dim NewWordFile As New Word.Application
    Dim NewDoc As New Word.Document
    Application.DisplayAlerts = False
    'Application.ScreenUpdating = False
    FolderName = "C:\Test\"
    FileName = Dir(FolderName)
    'Loop start
    Do While FileName ⋖⋗ ""
    Set NewDoc = NewWordFile.documents.Open(FolderName & FileName)
    NewDoc.Range(0, NewDoc.Range.End).Copy
    Range("LastRow").PasteSpecial xlPasteValues
    NewDoc.Close SaveChanges:=wdDoNotSaveChanges
    NewWordFile.Quit
    FileName = Dir()
    Loop
    End Sub
    -------
    Video Gears
    Mic used for Audio recording: amzn.to/32ZSagv
    Soundproofing Foam that I use, this also helps to reduce echo: amzn.to/2Dy939l
    For Video editing, I use Canva.com, you can join Canva by clicking here: www.canva.com/....
    Computer used for Editing: amzn.to/3bv9PjL
    Mobile used for video shooting: amzn.to/3gZP00X
    Reach out to me on Fiver for any excel automation projects: www.fiverr.com...
    #LearnExcelVBA #LearnExcelMacro

КОМЕНТАРІ • 27

  • @robinwilliams1913
    @robinwilliams1913 4 роки тому +1

    Thanks for sharing. Nicely explained. This is very useful. I was looking for such code for my project.

  • @ranajsingh
    @ranajsingh 2 роки тому

    It was superb Sir.. 🙏

  • @alex45598
    @alex45598 2 роки тому

    Hi thanks for your video! For some reason I keep running into an automation error at the "Set NewDoc=newWordFile.Documents.Open(FOldername & FileName)" any help? thanks

  • @robdav1es
    @robdav1es 2 роки тому

    Can the macro be modified to pick out a section from the word documents?

  • @sainaths1369
    @sainaths1369 2 роки тому

    Good explanation concept was easy to understand.
    Sir could you pls explain how make the folder name and file name dynamic

  • @CoderWave
    @CoderWave 3 роки тому

    I want to copy table from word where table has very large data in 1 cell which has some links and data formatting in it ...is there any way to copy as it is in excel

  • @ajaykumar-ml1dt
    @ajaykumar-ml1dt 3 роки тому +1

    How to copy only specific contents under the heading in the file for multiple word files to excel?

  • @HeelBusiness
    @HeelBusiness Рік тому

    Hello - I also come across error 462: the remote server machine does not exist or is unavailable. This happens after looping (the first run-through works perfectly)

  • @viswanathan19
    @viswanathan19 2 роки тому

    explanation is really great, thank you for the video.
    Help needed on my query is, how to copy data from a template and develop a table out of it

    • @LearnExcelVBA
      @LearnExcelVBA  2 роки тому

      Glad it was helpful! I havent tried that yet. I will check and get back to you.

  • @MohAboAbdo
    @MohAboAbdo Рік тому

    Thank you so much

  • @sachinsavadatti7148
    @sachinsavadatti7148 Рік тому

    I followed the same procedure and path but is is fetching data of only one word file. Remaining word file details it is not fetching. Can you help me on this.

  • @jgcelis
    @jgcelis 2 роки тому

    Hello, Thank you for posting such an awesome video. After hitting a couple of speed bumps I realized that I had to comment the line "NewWordFile.Quit" because for some reason it was giving me an error "Run-time error '462' - The remote server machine does not exist or is unavailable". Now I have been able to run the code just fine but I do have a question though. Is there a way to copy and paste an entire document into a single excel cell? For instance, if I were to have 5 MS Word documents in my file path, how would I go about pasting each document content into a single cell. Basically, 5 MS documents = 5 different rows. eg. A1, A2, A3, A4, A5. Thank you!

    • @zf485
      @zf485 2 роки тому

      Hi, I am getting the same error message. Where in the code did you add that additional line, of "NewWordFile.Quit"? Thanks!

    • @jgcelis
      @jgcelis 2 роки тому

      @@zf485 Hello, I commented the line. Basically removed it from the code. I hope it helps

  • @blancasanchez9765
    @blancasanchez9765 Рік тому

    The code worked but it does not find the last row it copies the subsequent document data just a few rows down and no after the last row.

  • @nyyamyrick9368
    @nyyamyrick9368 3 роки тому +1

    I got a message "the remote server does not exist or unavailable". Any tips on what to do next?

    • @LearnExcelVBA
      @LearnExcelVBA  2 роки тому

      Please Check that file paths are correct and accessible when running the code.

  • @gitanjalisingh1167
    @gitanjalisingh1167 Рік тому

    I am running the code but it is not giving any result nor showing error

  • @johnabram4159
    @johnabram4159 9 місяців тому

    Bro, the code keep pasting the same file. Doesn't loop.

  • @girishmuddebihalkar3804
    @girishmuddebihalkar3804 3 роки тому +1

    Hi it didn’t worked for me no files copied

    • @LearnExcelVBA
      @LearnExcelVBA  3 роки тому

      Hi Girish, Thanks for watching the video. Kindly make sure that file path is correct and it is ending with "\" & References under Tools should have Miscrosoft Word selected. If you have followed all the steps mentioned in the video. Kindly share what error you are getting.

    • @girishmuddebihalkar3804
      @girishmuddebihalkar3804 3 роки тому

      I hv 2 to 3 tables n many data in word files n I am trying to get data of two files in a folder . Done as per your videos but it’s just running for long time n not getting any out put.

    • @rexy2396
      @rexy2396 Рік тому

      Hi sir can I get the data from one word file to one sheet and another file to another sheet of excel. And so on