J
JS
Hi All:
I'm having some seriou troubles with PPT presentations that contain embedded
word objects (tables) for some time now.
I need to programmatically modify the contents of these tables (via a
Macro), but almost invariably the size/layout/configuration/etc of these
embedded word tables are modified (stretched, shrunck, cropped, etc.). The
embedded word tables are getting modified as the result of what I'm doing
programmatically, they are OK before running the Macro but get bunged up
AFTER running my code.
I posted this issue to the microsoft.public,powerpoint newsgroup and Steve,
bery helpfully, thinks this "...would seem to be mostly a Word problem; I'd
post in Public.Office.Developer.Automation about this..."
Does anyone have a clue as to what's going on? Below is the code I run.
Again, thanks for your attention and help. Rgds, JS
==========================
Sub EmbeddedWord_Replace_All_Ask()
Dim oSlide As Slide, oShape As Shape, oDoc As Word.Document
Dim SldNum As Long
Dim wdApp As Object, FindText As String, ReplaceText As String
FindText = InputBox("Enter text to be found (to be replaced)")
ReplaceText = InputBox("Enter replacement text")
On Error Resume Next: NewWordOpened = False
Set wdApp = GetObject(, "Word.Application")
If wdApp Is Nothing Then
Set wdApp = CreateObject("Word.Application"): NewWordOpened = True
Else
MsgBox ("There is one or more instances of WORD open")
End If
On Error GoTo 0
SldNum = 0
For Each oSlide In ActivePresentation.Slides
SldNum = SldNum + 1
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
wdDoc.Select
timeS = Time
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
If NewWordOpened Then wdApp.Quit
End Sub
I'm having some seriou troubles with PPT presentations that contain embedded
word objects (tables) for some time now.
I need to programmatically modify the contents of these tables (via a
Macro), but almost invariably the size/layout/configuration/etc of these
embedded word tables are modified (stretched, shrunck, cropped, etc.). The
embedded word tables are getting modified as the result of what I'm doing
programmatically, they are OK before running the Macro but get bunged up
AFTER running my code.
I posted this issue to the microsoft.public,powerpoint newsgroup and Steve,
bery helpfully, thinks this "...would seem to be mostly a Word problem; I'd
post in Public.Office.Developer.Automation about this..."
Does anyone have a clue as to what's going on? Below is the code I run.
Again, thanks for your attention and help. Rgds, JS
==========================
Sub EmbeddedWord_Replace_All_Ask()
Dim oSlide As Slide, oShape As Shape, oDoc As Word.Document
Dim SldNum As Long
Dim wdApp As Object, FindText As String, ReplaceText As String
FindText = InputBox("Enter text to be found (to be replaced)")
ReplaceText = InputBox("Enter replacement text")
On Error Resume Next: NewWordOpened = False
Set wdApp = GetObject(, "Word.Application")
If wdApp Is Nothing Then
Set wdApp = CreateObject("Word.Application"): NewWordOpened = True
Else
MsgBox ("There is one or more instances of WORD open")
End If
On Error GoTo 0
SldNum = 0
For Each oSlide In ActivePresentation.Slides
SldNum = SldNum + 1
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
wdDoc.Select
timeS = Time
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
If NewWordOpened Then wdApp.Quit
End Sub