Embedded Word table objects change size in PowerPoint 2003

  • Thread starter Thread starter JS
  • Start date Start date
J

JS

Hi All:

I'm been 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
tables are modified (stretched, shrunck, cropped, etc.).
I've scanned the Internet for articles on this and the closest I came to
was: http://support.microsoft.com/kb/249317/
but this is 2000 (I'm using PowerPoint/Word 2003 SP2).
Could someone please give me an idea of what to do?

Thanks so much, JS
 
Hi All:

I'm been 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
tables are modified (stretched, shrunck, cropped, etc.).

Can you explain in a bit more detail what you're up against?

It's not clear whether the problem is that the tables are getting modified as
the result of what you're doing programmatically, or that you're having to make
mods to the tables because they're already bunged.

Also, can you tell what type of tables they are? Word or Excel tables embedded
in PPT or native PPT tables?
 
Hi Steve: Thanks for replying.
The tables are getting modified as the result of what I'm doing
programmatically, and they are all Word tables embedded in PPT.
Again, thanks for your imput. Rgds, JS

Here's the code I run on the Presentation:
============================
Sub EmbeddedWord_Replace_All_Ask()
Dim oSlide As Slide: Dim oShape As Shape: Dim oDoc As Word.Document
Dim SldNum, Indice, IndiceMax As Long: Dim celtxt, timeS, TimeF, tStart,
tEnd As String
Dim wdCoc, wdApp As Object: Dim FindText, 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 =
CreateObject("Word.Application")
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
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
TimeF = Time
wdDoc.Save
wdApp.ActiveDocument.Close wdSaveChanges = False
End If
End If
Next oShape
End With
Next oSlide
If NewWordOpened Then wdApp.Quit
End Sub
 
Hi Steve: Thanks for replying.
The tables are getting modified as the result of what I'm doing
programmatically, and they are all Word tables embedded in PPT.
Again, thanks for your imput. Rgds, JS

Here's the code I run on the Presentation:
============================
Sub EmbeddedWord_Replace_All_Ask()
Dim oSlide As Slide: Dim oShape As Shape: Dim oDoc As Word.Document
Dim SldNum, Indice, IndiceMax As Long: Dim celtxt, timeS, TimeF, tStart,
tEnd As String

It may or may not matter in this case but did you know that your variables are
not what you think they are?

When you do:
Dim This, That, TheOther as Long

it's equivalent to:
Dim This as Variant
Dim That as Variant
Dim TheOther as Long
Dim wdCoc,

And should probably be wdDoc? If the compiler isn't barking at you over stuff
like this, you might want to add

Option Explicit

at the top of the declarations section of each of your modules. Let the
computer tell you when your fingers went off on their own and did something
silly. ;-)

Beyond that it would seem to be mostly a Word problem; I'd post in
Public.Office.Developer.Automation about this. But first, just before you do
WdApp.Quit add WdApp.Update


wdApp As Object: Dim FindText, ReplaceText As String
 
Hi Steve: Thanks so much for your reply.
Aaahhh... did not know about ...This, That,... being Variant!!! This
explains lots of other things :) [but unfortunately not this
problem...well... one thing at a time...]
Also, upon adding wdApp.update to "If NewWordOpened Then wdApp.Quit"
becoming [If NewWordOpened Then wdApp.Update: wdApp.Quit] I get barked at
with "Object doesn't support this property or method" (however, I did add
"wdDoc.Save" withing the find&replace loop in the code - is this the same
thing?)
I'll post this to the newsgroup you suggested and see what I get.
Steve, again, thanks for your inputs and time! They are valued!!
Rgds, JS
 
Hi Steve: Thanks so much for your reply.
Aaahhh... did not know about ...This, That,... being Variant!!! This
explains lots of other things :) [but unfortunately not this
problem...well... one thing at a time...]

Right ...not a problem in this case, but some weird little bugs can creep in
when you let VB "help" you with variables. Best to lead it by the nose to
where you want it. I see you've done that in the code you posted in the other
group, and that you and Cindy Meister have found one another. Good ... she's
first-rate.
Also, upon adding wdApp.update to "If NewWordOpened Then wdApp.Quit"
becoming [If NewWordOpened Then wdApp.Update: wdApp.Quit] I get barked at
with "Object doesn't support this property or method" (however, I did add
"wdDoc.Save" withing the find&replace loop in the code - is this the same
thing?)

Nuts. I was hoping that'd be the answer ... it frequently is when you're
working with Graph objects in similar ways.
 
JS,
try getting the .top, .left, .width and .heightas variables before
you activate Word.
Then when you are done with Word set the shapes dimensions to those
variables.

Brian Reilly, MVP
 
Back
Top