ranjith2523
Board Regular
- Joined
- Apr 29, 2014
- Messages
- 137
- Office Version
- 365
Hello Experts,
Yes, i understand we have multiple threads with the same topic. Before i posting this question i reviewed most of the thread but i didn't get an expected solution.
I am using Office 365 and I just tried the below coding and either it is running for a long time or getting error at "objWord.Selection.WholeStory".
My basic expectation is to simply copy the entire word file (INCLUDING HEADER) and paste it in a specific Tab. (As how we manually do it from Word to Excel)
I would be very helpful for me if anyone help me on this.
Regards,
Ranjith
Yes, i understand we have multiple threads with the same topic. Before i posting this question i reviewed most of the thread but i didn't get an expected solution.
I am using Office 365 and I just tried the below coding and either it is running for a long time or getting error at "objWord.Selection.WholeStory".
My basic expectation is to simply copy the entire word file (INCLUDING HEADER) and paste it in a specific Tab. (As how we manually do it from Word to Excel)
I would be very helpful for me if anyone help me on this.
VBA Code:
Sub ImportSectHWord()
Dim objWord As Object
Dim objDoc As Object
Dim wdFileName
Set objWord = CreateObject("word.Application")
wdFileName = Application.GetOpenFilename("Word Documents, *.doc*")
If wdFileName = False Then Exit Sub
Set objDoc = GetObject(wdFileName)
objWord.Documents.Open (wdFileName)
objWord.Selection.WholeStory
Selection.Copy
Thisworkbook.sheets("Word").Range("A1").Select
ActiveSheet.Paste
objDoc.Close SaveChanges:=wdDoNotSaveChanges
objWord.Quit
End Sub
Regards,
Ranjith