Hi all....
All I'm trying to do is to "read" a Word 2010 document in Excel 2010 using Excel VBA.
I've tried various different ways of coding this
This one -
generates
Run-time error '-2147221164 (80040154)':
Class not registered.
Prior to this I tried
This gets:-
Run-time error '-2147319779 (8002801d)':
Automation error
Library not registered
I have Tools/References to
Visual Basic for Applications
Microsoft Excel 14.0 Object Library
OLE Automation
Microsoft Office 14.0 Object Library
Microsoft Forms 2.0 Object Library
Microsoft Scripting Runtime
Microsoft Word 14.0 Object Library
Incidentally, after a lot of Googling, I found and executed Microsoft's
MicrosoftEasyFix25011.mini.diagcab
This seemed to "reset" some long-standing Excel options, but had no effect on the errors.
Can any kind soul offer a solution, help or advice?
All I'm trying to do is to "read" a Word 2010 document in Excel 2010 using Excel VBA.
I've tried various different ways of coding this
This one -
VBA Code:
Option Explicit
Sub Main()
Dim oWDoc As Word.Document
Dim oWord As Word.Application
Dim strPath As String
Dim oWPara As Word.Paragraph
strPath = "I:\test.doc"
Set oWord = Word.Application
Set oWDoc = oWord.Documents.Open(strPath)
For Each oWPara In oWDoc.Paragraphs()
'Do something
Next oWPara
Cleanup:
oWDoc.Close
Set oWDoc = Nothing
oWord.Quit
Set oWord = Nothing
End Sub
Run-time error '-2147221164 (80040154)':
Class not registered.
Prior to this I tried
VBA Code:
Sub Copy_From_Word()
Dim objDoc As Object
Dim objPara As Object
Dim objWord As Object
Dim strPath As String
'*
'** Open a Word Document and Set it to the
'** newly created object above
'*
strPath = "I:\test.doc"
Set objWord = CreateObject("Word.Application")
Set objDoc = objWord.Documents.Open(strPath)
'*
'** Store all the content of that Word
'** Document in a variable.
'*
For Each objPara In objDoc
' If objPara.Type = wdParagraph Then
' Do something
Next objPara
objDoc.Close SaveChanges:=wdDoNotSaveChanges
objWord.Quit
Set objDoc = Nothing
Set objWord = Nothing
End Sub
Run-time error '-2147319779 (8002801d)':
Automation error
Library not registered
I have Tools/References to
Visual Basic for Applications
Microsoft Excel 14.0 Object Library
OLE Automation
Microsoft Office 14.0 Object Library
Microsoft Forms 2.0 Object Library
Microsoft Scripting Runtime
Microsoft Word 14.0 Object Library
Incidentally, after a lot of Googling, I found and executed Microsoft's
MicrosoftEasyFix25011.mini.diagcab
This seemed to "reset" some long-standing Excel options, but had no effect on the errors.
Can any kind soul offer a solution, help or advice?