J
John Svendsen
Hi All,
I have a problem that is plaguing me. I need to constantly modify many
embedded Word objects in several PPT files. To do so I've put together a PPT
VBA code that does this, BUT if I have another instance of word running
(which many times I need to have) the code fails at the set command in the
code with the following error:
Run-time error '-2147220995 (800401fd)':
Method 'Object' of object 'OLEFormat' failed
I've done research on this (e.g.,
http://support.microsoft.com/default.aspx?scid=kb;en-us;189618) but no luck
if fixing this SET problem.
Can someone give me an idea of what to do?
Thanks so much, JS
Sub EmbeddedWord_Replace_All_Ask()
Dim oSlide As Slide
Dim oShape As Shape
Dim oDoc As Word.Document
Dim wdApp As Object
Dim FindText, ReplaceText As String
FindText = InputBox("Enter text to be found (to be replaced)")
ReplaceText = InputBox("Enter replacement text")
Set wdApp = CreateObject("Word.Application")
For Each oSlide In ActivePresentation.Slides
With oSlide
For Each oShape In .Shapes
If oShape.Type = msoEmbeddedOLEObject Then
If oShape.OLEFormat.ProgID = "Word.Document.8" Then
'======================================================
Set wdDoc = oShape.OLEFormat.Object '<<<=== CODE FAILS HERE
'======================================================
wdDoc.Select
With wdApp.Selection.Find
.Text = FindText
.ClearFormatting
.Replacement.Text = ReplaceText
.Replacement.ClearFormatting
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = True
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.Execute Replace:=wdReplaceAll
End With
wdDoc.Save
wdApp.ActiveDocument.Close wdSaveChanges = False
End If
End If
Next oShape
End With
Next oSlide
wdApp.Quit
End Sub
I have a problem that is plaguing me. I need to constantly modify many
embedded Word objects in several PPT files. To do so I've put together a PPT
VBA code that does this, BUT if I have another instance of word running
(which many times I need to have) the code fails at the set command in the
code with the following error:
Run-time error '-2147220995 (800401fd)':
Method 'Object' of object 'OLEFormat' failed
I've done research on this (e.g.,
http://support.microsoft.com/default.aspx?scid=kb;en-us;189618) but no luck
if fixing this SET problem.
Can someone give me an idea of what to do?
Thanks so much, JS
Sub EmbeddedWord_Replace_All_Ask()
Dim oSlide As Slide
Dim oShape As Shape
Dim oDoc As Word.Document
Dim wdApp As Object
Dim FindText, ReplaceText As String
FindText = InputBox("Enter text to be found (to be replaced)")
ReplaceText = InputBox("Enter replacement text")
Set wdApp = CreateObject("Word.Application")
For Each oSlide In ActivePresentation.Slides
With oSlide
For Each oShape In .Shapes
If oShape.Type = msoEmbeddedOLEObject Then
If oShape.OLEFormat.ProgID = "Word.Document.8" Then
'======================================================
Set wdDoc = oShape.OLEFormat.Object '<<<=== CODE FAILS HERE
'======================================================
wdDoc.Select
With wdApp.Selection.Find
.Text = FindText
.ClearFormatting
.Replacement.Text = ReplaceText
.Replacement.ClearFormatting
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = True
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.Execute Replace:=wdReplaceAll
End With
wdDoc.Save
wdApp.ActiveDocument.Close wdSaveChanges = False
End If
End If
Next oShape
End With
Next oSlide
wdApp.Quit
End Sub