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
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?
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
Last edited by a moderator: