Import word doc into excel and keep formatting

stuartroberts1978

New Member
Joined
Sep 25, 2019
Messages
1
Im trying to import a word doc into and excel sheet, which i can with the use of vba, here is my code
Code:
Sub cmdbtnImportwordDoc_Click()
   Dim docAppl As Word.Application, docMyDoc As Word.document
   Dim SourceFile As String
   Dim Dest As Range
   Dim wbkSource As Workbook
   Dim SourceRange As Range
   Dim SourceData
   With Application.FileDialog(msoFileDialogFilePicker)
      .Filters.Clear
      .AllowMultiSelect = False
      If .Show = -1 Then
         SourceFile = .SelectedItems(1)
      End If
   End With
   Set docAppl = CreateObject("Word.Application")
   Set docMyDoc = Documents.Open(SourceFile)
   With docMyDoc
      .Range(start:=0, End:=.Characters.Count).Copy
   End With
   [A9].Select
   ActiveSheet.Paste
   Set docMyDoc = Nothing
   Set docAppl = Nothing
End Sub
it works as should, the doc has text and tables in there so when i import it, all the content is filled in from the left hand cell, is there a way to keep the same formatting from the word doc?
 
Last edited by a moderator:

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.

Forum statistics

Threads
1,223,164
Messages
6,170,444
Members
452,326
Latest member
johnshaji

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
Back
Top