Тёмный

How to import data from Word tables into Excel with VBA 

Dinesh Kumar Takyar
Подписаться 115 тыс.
Просмотров 40 тыс.
50% 1

Our Excel training videos on RU-vid cover formulas, functions and VBA or macros. Useful for beginners as well as advanced learners. New upload every Thursday.
For details you can visit our website:
www.exceltrainingvideos.com/ho...
Importing data from Word tables into Excel with VBA can be quite useful for further calculations and data analysis.
The first step involves the access of the Word document. Next we access the tables in the Word document using a looping code that automates the complete process.

Опубликовано:

 

5 авг 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 52   
@DrFunkNStein-ol4zo
@DrFunkNStein-ol4zo 5 лет назад
Dinesh! My man! Thank you so much! Have a great summer and KIT!
@mail2arunjith
@mail2arunjith 6 лет назад
Thank you for this wonderful video. This was exactly what i was looking for and you have saved my day.
@jacodevilliers1937
@jacodevilliers1937 4 года назад
Great Work and Thanks!
@Exceltrainingvideos
@Exceltrainingvideos 4 года назад
You are welcome. Please share with your friends also.
@cpkoek
@cpkoek 8 лет назад
can we use this application to extract data from multiple word to 1 excel file? every incremental of the word files will also appear in the excel. actually i wanted to compile all required information in all release revision in 1 excel, not sure it is durable?
@BJNLAZAREVIC
@BJNLAZAREVIC 7 лет назад
Dear Mr. Dinesh, I was searching for the method to import text from Word into Excel and found this video of yours. In my case I would simply need to copy the first line of the textual document at the Page1 (Word) and to copy it to Sheet 1 in Excel. I have 250 such pages in Word and I need VBA macro to perform aforementioned operation automatically for every single page(word)/sheet(excel). Is it feasible? I searched about 4 hours for the solution online and haven't managed to found one.
@Kotiekotie
@Kotiekotie Год назад
Can we get each table in separate sheets in excel. Please tell
@darthsavage4025
@darthsavage4025 4 года назад
Thank you very much for the awesome tutorial! If I have a Word file that includes 4 tables; and I want each table to be added to their own sheet (which would need to be created); how would I accomplish this?
@Exceltrainingvideos
@Exceltrainingvideos 4 года назад
Sub importTableDataWord() Dim WdApp As Object, wddoc As Object Dim strDocName As String On Error Resume Next Set WdApp = GetObject(, "Word.Application") If Err.Number = 429 Then Err.Clear Set WdApp = CreateObject("Word.Application") End If WdApp.Visible = True strDocName = "C:\our-inventory\inventory.docx" If Dir(strDocName) = "" Then MsgBox "The file " & strDocName & vbCrLf & _ "was not found in the folder path" & vbCrLf & _ "C:\our-inventory\.", _ vbExclamation, _ "Sorry, that document name does not exist." Exit Sub End If WdApp.Activate Set wddoc = WdApp.Documents(strDocName) If wddoc Is Nothing Then Set wddoc = WdApp.Documents.Open(strDocName) wddoc.Activate Dim Tble As Integer Dim rowWd As Long Dim colWd As Integer Dim x As Long, y As Long x = 1 y = 1 With wddoc Tble = wddoc.tables.Count Worksheets.Add after:=Sheet1, Count:=(Tble - 1) 'MsgBox Tble If Tble = 0 Then MsgBox "No Tables found in the Word document", vbExclamation, "No Tables to Import" Exit Sub End If j = 1 For i = 1 To Tble With .tables(i) For rowWd = 1 To .Rows.Count For colWd = 1 To .Columns.Count Sheets("Sheet" & j).Cells(x, y) = WorksheetFunction.Clean(.cell(rowWd, colWd).Range.Text) y = y + 1 Next colWd y = 1 x = x + 1 Next rowWd End With j = j + 1 y = 1 x = 1 If j > Tble Then wddoc.Close Savechanges:=False End If Next i End With WdApp.Quit Sheet1.Range("A1").Select Set wddoc = Nothing Set WdApp = Nothing End Sub
@john-vb5fw
@john-vb5fw 8 лет назад
Hi Dinesh im struggling with a project could you help via email so i can send a file to you with a description of what i need ?
@JokoEngineeringhelp
@JokoEngineeringhelp 9 лет назад
If I am getting "No Tables Found in word document" and when I remove on error remove next I find that GetObject and CreateObject both don't create the word application. (Getting Error 429 still) Any suggestions?
@corneliusmertzlufft-paufle1726
Joko Engineeringhelp did you receive any hints to solve the problem? I encounter the same.
@corneliusmertzlufft-paufle1726
Thank you for this valuable code. However, if my table contains numbers (currency), it will convert to text, not to numbers format. This makes it difficult to process the imported numbers. Do you have a solution for this?
@Exceltrainingvideos
@Exceltrainingvideos 5 лет назад
I had no problems: www.exceltrainingvideos.com/how-to-import-data-from-word-tables-into-excel-with-vba/
@barbarawarren6203
@barbarawarren6203 6 лет назад
Hello Sir, Can you do a similar video for copying data from Word to Excel that shows how to loop through multiple Word files in a folder?
@Exceltrainingvideos
@Exceltrainingvideos 6 лет назад
Use a looping process to access each file. This video will guide: www.exceltrainingvideos.com/transfer-data-multiple-workbooks-master-workbook-automatically/ Or search my website www.exceltrainingvideos.com
@mouneshwarbadiger7335
@mouneshwarbadiger7335 6 лет назад
Hi Sir, Thank you so much for this video, I observed that it is not copying the format of the text(Ex : if some of the words are bold in word file then those are not copying with the same format). could you please help me to get the format also....
@Exceltrainingvideos
@Exceltrainingvideos 6 лет назад
www.exceltrainingvideos.com/copy-data-paste-another-workbook-transpose-automatically-using-excel-vba/ www.exceltrainingvideos.com/paste-special/ www.exceltrainingvideos.com/how-to-copy-a-word-table-into-excel/
@mouneshwarbadiger7335
@mouneshwarbadiger7335 6 лет назад
These links are useful only if we are doing manually, is it possible to add a paste special option in this video's code itself? so that it can copy the word file table data(with the format) and paste it into excel(with the same format).
@abhisheksomashekar2259
@abhisheksomashekar2259 3 года назад
Hello Dinesh Sir, I want to know how to copy a specific table in a Word Document from a group of tables to another word document? Can you please help
@Exceltrainingvideos
@Exceltrainingvideos 3 года назад
Will work on this good idea.
@khajamk9258
@khajamk9258 3 года назад
Hi sir I need your help I want to copy data only which is in numbers . Is this possible from word to excel. Please reply. Thanks.
@Exceltrainingvideos
@Exceltrainingvideos 3 года назад
Yes. This link will guide: www.exceltrainingvideos.com/how-to-extract-numbers-from-alphanumeric-text-in-excel/
@srinivassri7067
@srinivassri7067 3 года назад
Sir, Could you help in providing a solution for the below problem. There are multiple tables in my word document. How can i extract specific tables having data into excel sheet using word VBA. I do not want all tables to be imported. each tables has different columns and data with merged columns in it.
@Exceltrainingvideos
@Exceltrainingvideos 3 года назад
Will work on this idea.
@stefaniecheng
@stefaniecheng 3 года назад
Is it possible to transfer the content table-within table from word into excel using vba?
@Exceltrainingvideos
@Exceltrainingvideos 3 года назад
Give an example.
@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
@Exceltrainingvideos
@Exceltrainingvideos 3 года назад
Try copy pastespecial. This Excel VBA tutorial will also help: www.exceltrainingvideos.com/how-to-import-data-from-word-tables-into-excel-with-vba/ You can search this channel or our website.
@CoderWave
@CoderWave 3 года назад
@@Exceltrainingvideos link is not working but I want 50 lines data in a single cell with different formatting on each line with some hyperlink in data . Will it help?
@deepakbhanushali1
@deepakbhanushali1 4 года назад
what a wonderful video thank Sir Sir I did the same but one problem presist in word file table i want to insert row 1,2 and skip 3 and 4 ,5 skip 6 in a multiple (skiping all the rows multiple by 3) what should be done in my word tabel 1row2column value is 2020.04 and 2ndrow3coumn its date (25) can it be merged while replace it in excel vba
@Exceltrainingvideos
@Exceltrainingvideos 4 года назад
In the 'for loop' you can use step 3. eg. For i= 1 to x step 3
@deepakbhanushali1
@deepakbhanushali1 4 года назад
@@Exceltrainingvideos thanks sir it worked
@jsprite123
@jsprite123 8 лет назад
It would really help if you indent your "If" and "For" statements, otherwise it is hard to follow.
@Exceltrainingvideos
@Exceltrainingvideos 8 лет назад
OK
@Exceltrainingvideos
@Exceltrainingvideos 6 лет назад
These links will guide: www.exceltrainingvideos.com/copy-data-paste-another-workbook-transpose-automatically-using-excel-vba/ www.exceltrainingvideos.com/paste-special/ www.exceltrainingvideos.com/how-to-copy-a-word-table-into-excel/
@kamalakotagiri7174
@kamalakotagiri7174 4 года назад
Hi Dinesh- Can we snip some part of word doc paste into Excel as image? Please reply
@Exceltrainingvideos
@Exceltrainingvideos 4 года назад
I use the Fn + PRT SC keys to take a snap.
@kamalakotagiri7174
@kamalakotagiri7174 4 года назад
@@Exceltrainingvideos I need VBA solution to capture a table as bitmap. Is it possible ?
@Exceltrainingvideos
@Exceltrainingvideos 4 года назад
Need VBA solution? Ready to pay for it?
@aceace4917
@aceace4917 3 года назад
Hi Sir! I've got an error of Variable not defined for "i". What should I do?
@Exceltrainingvideos
@Exceltrainingvideos 3 года назад
Declare the variable i. Dim i as Long
@thaddeusspann1039
@thaddeusspann1039 4 года назад
Code doesn't work. Says no tables found when there are hundreds of tables.
@Exceltrainingvideos
@Exceltrainingvideos 4 года назад
Check your code here. You'll also be able to download the actual file for practice: www.exceltrainingvideos.com/how-to-import-data-from-word-tables-into-excel-with-vba/
@majidal-haddabi6302
@majidal-haddabi6302 9 лет назад
can you send us the VBA code for this application
@Exceltrainingvideos
@Exceltrainingvideos 9 лет назад
+Majid Al-Haddabi www.exceltrainingvideos.com/how-to-import-data-from-word-tables-into-excel-with-vba/
@lenovoomobile8518
@lenovoomobile8518 8 лет назад
I have a table in microsoft word. Table format is same on 20 pages but entries are different. I want to import this data in excel but in specific rows and columns in excel. Columns title is same as in different entries of word. How can I import this data so that all data of one table in work should be imported in one row of excel. Thanks
@boriszaitsev3211
@boriszaitsev3211 3 года назад
How to do it work with nested table?!
@Exceltrainingvideos
@Exceltrainingvideos 3 года назад
Can you elaborate?
@boriszaitsev3211
@boriszaitsev3211 3 года назад
@@Exceltrainingvideos For example, document has different tables. Some of them have nested tables. It is necessary to extract data from table with cells size 16*N (lets name it "D"). It is fourth nested table in another parent table in cell 1,1 (lets name it "C"). Table "C" is second nested in another parent table "B" in cell 1,1. Table "A" has only one nested table "B" in cell 1,1.
@xuenen
@xuenen 9 лет назад
Why dimming as generic Object? You have to do the CreateObject and GetObject and you have no Intellisense. You could have done this to avoid all of that: Dim wdApp As New Word.Application Dim wdDoc As Word.Document
@Exceltrainingvideos
@Exceltrainingvideos 9 лет назад
Alan Sonnenberg Thanks!
Далее
Extract Specific Data from MS Word into Excel with VBA
10:56
Why The Windows Phone Failed
24:08
Просмотров 231 тыс.
VBA to BROWSE & COPY Data from SELECTED File in Excel
10:00
VLOOKUP Using VBA
21:23
Просмотров 302 тыс.
How to create report from Excel data sheet with VBA
20:46
How to update excel worksheet data with userform
19:49
Просмотров 118 тыс.