Copying from Word to Excel

sbyers2

New Member
Joined
Sep 14, 2006
Messages
5
I am trying to copy a word document into an excel tab, but if i just do it directly it populates across, and if i paste special as a word file, it leaves certain paragraphs out....any suggestions? Also, a side question. I have a large file with 100 or so tabs. All are protected, but I noticed a mistake and need to fix it on each tab. Is it possible to unprotect all of them at once? or do I have to do each one individually
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)

xapie128

Board Regular
Joined
Aug 26, 2006
Messages
82
Also, a side question. I have a large file with 100 or so tabs. All are protected, but I noticed a mistake and need to fix it on each tab. Is it possible to unprotect all of them at once?
Create and run a macro with the following:
Code:
    For index = 1 To Worksheets.Count
      Worksheets(index).Unprotect
    Next
You can change all worksheets back to protected by changing the "Unprotect" to "Protect" and running it again.
 

VoG

Legend
Joined
Jun 19, 2002
Messages
63,650
If the data in the Word doc is in tables then the following macro will import correctly into Excel.

Code:
Sub ImportWordTable()
Dim wdDoc As Object
Dim wdFileName As Variant
Dim TableNo As Integer 'table number in Word
Dim iRow As Long 'row index in Excel
Dim iCol As Integer 'column index in Excel
wdFileName = Application.GetOpenFilename("Word files (*.doc),*.doc", , _
"Browse for file containing table to be imported")
If wdFileName = False Then Exit Sub '(user cancelled import file browser)
Set wdDoc = GetObject(wdFileName) 'open Word file
With wdDoc
TableNo = wdDoc.tables.Count
If TableNo = 0 Then
MsgBox "This document contains no tables", _
vbExclamation, "Import Word Table"
ElseIf TableNo > 1 Then
TableNo = InputBox("This Word document contains " & TableNo & " tables." & vbCrLf & _
"Enter table number of table to import", "Import Word Table", "1")
End If
With .tables(TableNo)
'copy cell contents from Word table cells to Excel cells
For iRow = 1 To .Rows.Count
For iCol = 1 To .Columns.Count
Cells(iRow, iCol) = WorksheetFunction.Clean(.cell(iRow, iCol).Range.Text)
Next iCol
Next iRow
End With
End With
Set wdDoc = Nothing
End Sub

Unfortunately I can't remembere who first posted this :oops: so I can't give them the credit.
 

Forum statistics

Threads
1,141,626
Messages
5,707,483
Members
421,510
Latest member
haroonstr

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top