jamescooper
Well-known Member
- Joined
- Sep 8, 2014
- Messages
- 834
Hello,
Trying to copy a word document to Excel, literally a data dump as a typical manual copy would do, the code I have so far is:
I am unsure how to adapt the strTemp bit to ensure to copy all across.
Many thanks in advance.
Trying to copy a word document to Excel, literally a data dump as a typical manual copy would do, the code I have so far is:
I am unsure how to adapt the strTemp bit to ensure to copy all across.
Many thanks in advance.
VBA Code:
Sub Copy_Raw_Data()
'Application.DisplayAlerts = False 'Disable all the Alerts from excel
'Application.ScreenUpdating = False 'After opening Word Doc, Document will not be visible
'Create a New Object for Microsoft Word Application
Dim objWord As New Word.Application
'Create a New Word Document Object
Dim objDoc As New Word.Document
'Open a Word Document and Set it to the newly created object above
Set objDoc = objWord.Documents.Open("C:\Risk assessor\Data\PTI Risk Assessments\PTIReport (6).doc")
'To Store all the content of that word Document in a variable
strTemp = objDoc.Range(0, objDoc.Range.End)
'Now store that variable value in to a cell range
Range("A1").Value = strTemp
str1 = objDoc.Range(0, 1)
Range("A2").Value = str1
Range("B2").Value = strTemp
objDoc.Close SaveChanges:=wdDoNotSaveChanges
objWord.Quit
End Sub