Embedded Word table objects change size in PowerPoint 2003 when running a macro

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
 
C

Cindy M.

Hi Js,

Hah! And I was getting ready to send you back to the PPT group...

I think the problem may be in how PPT and Word are communicating, with Word as
OLE Server and PPT as OLE Client. There's a similar problem with working with
Excel stuff in Word. In that case, it's Word + the printer driver thinking it
has to resize the Excel object to fit in the Word margins.

I guess one thing you need to test is whether performing the same actions in
the UI (opening the object in a separate Word window, performing Find/Replace,
then closing the document) have a similar effect.
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

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 
J

JS

Hi Cindy:
Thanks for replying.
Yes, if I double-click the embedded word table and run Find&Replace, this
also bunges up the object.
Any idea what this is about?
Again, thanks for your time (& brains). Rgds, JS
 
S

Steve Rindsberg

Hi Js,

Hah! And I was getting ready to send you back to the PPT group...

<g> Looks to me like the code in PPT's just going "Yo, Word. Change this." or
maybe "Yo, COM. Get Word to change this."

If it also happens when you do this stuff manually (good call on that one) it
seems the code's ok, but the interaction between the two apps is at fault.

We get a lot of complaints from users who have similar problems with Excel stuff
in PPT, while other folks never see it.
 
C

Cindy M.

Hi Steve,
We get a lot of complaints from users who have similar problems with Excel stuff
in PPT, while other folks never see it.
Next time you see this, and the person has access to a number of printers
(including one that uses or can use old HP Laserjet drivers), have them test with
various printers/drivers. Someone showed up in one of the Word groups the other day
and said he figured out it was the interaction with the printer drivers. Using some
old HP Laserjet 5-series everything was as nice and stable as could be.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply in
the newsgroup and not by e-mail :)
 
C

Cindy M.

Hi Js,
Yes, if I double-click the embedded word table and run Find&Replace, this
also bunges up the object.
Any idea what this is about?
See my reply to Steve. I imagine it's a similar kind of thing. If you can
play around with various printer drivers it would be interesting to find
out if you see any differences.

As far as solutions go, here's an idea to test:

Open the original document with the table. Run the Find/Replace in the
document. Now update the link in PPT. (If you currently aren't set up this
way, set up a test set of files.)

If that doesn't work properly, what about if you copy the Word table and
paste it into PPT (replacing what's there)?

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 
J

JS

Hi Cindy/Steve:
As per your suggestion, I've tried 4 different printer drivers (HP
Laserjet-5, OkiPage 8z, Epson Stylus C45 & PDF printer) - all make no
differences: the embedded word tables bunge up as before.
Unfortunately, I receive the PPT files 'as-is' (with the embedded word
tables already in it - I do not have access to the original word files);
plus, usually, there are a couple hundred or so embedded word tables in each
PPT file I need to manipulate. To make matters worse, in most cases,
analysts insert PPT objects ON TOP OF the embedded tables (colored circles,
rectangles, etc.) to highlight certain cells of these tables - mind you,
these are NOT part of the embedded word object! - thus, ANY change in
size/position/etc. of the embedded word tables also compromises these
highlighting effects... a real headache (migraine!!)... Is this something
that is referable to MS itself, or........

Again, thanks for your efforts - JS
 
C

Cindy M.

Hi Js,
Is this something
that is referable to MS itself, or........
Well, you always have the option of going through paid
support.

I'd be happy to chip away at this with you, if you wish.
But you'll have to set up test scenarios as I describe so
that we can see if there is a basic way to get at this
stuff without it changing size on you.

Hmmm. New thought. I wonder if the size comes from the Word
object having been *created* in a different version of
Office and/or with a different printer driver. Any chance
you can get this information for one of the files?

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update
Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any
follow question or reply in the newsgroup and not by e-mail
:)
 
J

JS

Hi Cindy:
Thanks for your offer to chip at this, I truly appreciate your help.
As to "...object *created* in a different version of Office and/or with a
different printer driver..." - I do believe so, and I'll try to get an
original file, but even if I am successful in getting one, I know that these
come from many different sources and service providers.
Would it be helpful to have a PPT file with this issue? I've create a
1-slide and 1-macro PPT that summarizes this problem.
Again, thanks for looking at this - this is a REAL headache.
Rgds, JS
 
C

Cindy M.

Hi Js,
As to "...object *created* in a different version of Office and/or with a
different printer driver..." - I do believe so, and I'll try to get an
original file, but even if I am successful in getting one, I know that these
come from many different sources and service providers.
Would it be helpful to have a PPT file with this issue?
What I'm after is tracking down where the problem comes from, and if there's
anything you can do to get around it. (I have no intention of working with
your files, myself BTW) It appears to be an issue with how the apps are
dealing with changing printer drivers and Office versions, so anything we come
up with probably won't be "pretty" - if we can come up with anything at all!

Besides getting an original Word file, you should also see if you can't get
information on the version of Office, as well as the printer driver (printer
name and driver version, if you can manage it).

While you're waiting, there is a thought... You've not mentioned which version
of Office *YOU* use? Since, oh, Word 2002 I think, in
Tools/Options/Compatibility there's an entry for "Use printer metrics". If you
double-click a Word table, then got into Tools/Options/Compatibility what is
the setting for that option? And if you change the setting, does that have any
effect on the result?

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 
J

JS

Hi Cindy,
Sorry: I'm using MS Office Word 2003 (11.6568.6568) SP2 + MS Office
PowerPoint 2003 (11.6564.6568) SP2 (Part of MS Office Standard Edition 2003)
English. (Microsoft Windows XP Home Edition Version 5.1.2600 Service Pack 2
Build 2600)
As to the Tools->Options->Compatibility when double-clicking the embedded
Word objetc, I get: Recommnded options for: 'MS Office Word 200' and in the
Options box, *none* of the 50 option boxes are checked. Any idea what
options to play with, and in what order (i.e., before/after the marco that
bunges)?
Thanks for your help - JS
 
C

Cindy M.

Hi Js,
As to the Tools->Options->Compatibility when double-clicking the embedded
Word objetc, I get: Recommnded options for: 'MS Office Word 200' and in the
Options box, *none* of the 50 option boxes are checked. Any idea what
options to play with, and in what order (i.e., before/after the marco that
bunges)?
As I said: Use printer metrics to layout document

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 
J

JS

Hi Cindy,
OK, if I double-click the embedded word table and check 'use printer metrics
to layout document' THEN run the macro - bunges up as before. If I run the
macro (bunges up) and THEN check 'use printer metrics to layout document' -
no change (continues bunged up). The only thing that changes with 'use
printer metrics to layout document' is that the FONT changes a little to
adjust to the printer (some text becomes longer, causing cells to wrap -
changing the layout [position] of table cells).
Another thing that occurs: the size/position of the embedded word object in
PPT's Format Object changes: original size/pos (h=2.59&w=9.07/h=0.45&v=2.56)
changes to size/pos (h=1.23&w=9.57/h=0.46&v=3.24) when running the macro -
however, if I double-click and manually change something, the size/pos
changes to (h=5.05&w=8.98/h=0.45&v=2.56) - wierd...
Still haven't been able to get original word doc/sys info.
Thanks and regards, JS
 
S

Steve Rindsberg

Next time you see this, and the person has access to a number of printers
(including one that uses or can use old HP Laserjet drivers), have them test with
various printers/drivers. Someone showed up in one of the Word groups the other day
and said he figured out it was the interaction with the printer drivers. Using some
old HP Laserjet 5-series everything was as nice and stable as could be.

Will do. Mostly the complaint's about content from Excel, which doesn't seem quite so
tied to the current printer driver as Word, but it's still worth a look.

Another thought that might help an AHA be born. Or not.

With MSGraph charts and charts from Excel, there are two different sizes, that set in
the originating app and that set by changing the size of the OLE object in the host
app. e.g you can size the chart while it's activated in MSGraph (and it works
reasonably well) or you can click back out of Graph and size the de-activated chart as
a PPT object (which distorts it).

Could something similar be happening with these Word tables?
 
C

Cindy M.

Hi Steve,
Another thought that might help an AHA be born. Or not.

With MSGraph charts and charts from Excel, there are two different sizes, that set in
the originating app and that set by changing the size of the OLE object in the host
app. e.g you can size the chart while it's activated in MSGraph (and it works
reasonably well) or you can click back out of Graph and size the de-activated chart as
a PPT object (which distorts it).

Could something similar be happening with these Word tables?
That's a possibility, I guess (not that I'm *that* familiar with anything newer than PPT
4.0 <g>). And here's a related thought:

Word does a better job handling Excel charts that are 1. On a separate sheet and 2.
"Sized to fit" in Excel. As soon as Word has to start "translating" Excel sizes into
Word, things become a lot less stable.

I wonder, if one would start with a Word table that has
- static column widths (rather than "fit to content")
- that are sized to fit on the Powerpoint slide (rather than Word's page width)

if that would be more stable?

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply in the
newsgroup and not by e-mail :)
 
S

Steve Rindsberg

Hi Cindy,

[snippage]
That's a possibility, I guess (not that I'm *that* familiar with anything newer than PPT
4.0 <g>). And here's a related thought:

Word does a better job handling Excel charts that are 1. On a separate sheet and 2.
"Sized to fit" in Excel. As soon as Word has to start "translating" Excel sizes into
Word, things become a lot less stable.

Bingo. Exactly the same as in PPT (both Excel charts and MSGraph ones)
I wonder, if one would start with a Word table that has
- static column widths (rather than "fit to content")
- that are sized to fit on the Powerpoint slide (rather than Word's page width)

if that would be more stable?

Good question. I just did a bit of testing and found a whole new question that trumps this
so let's put it aside for a second. <g>

When you copy/paste a table from Word 2003 to PPT 2003, you no longer get an embedded Word
object as you once did. You get a PowerPoint Table; the size seems somewhat governed by
the autofit settings in the original Word table but once it's in PPT all that apparently
gets left behind.

Also left behind, it seems, is the ability to PasteSpecial a table as a Word document
object. Oh, you can DO it, but you don't want to, not if the results are as awful as what
I'm getting here. Tables with bottoms lopped off, tables cut in half vertically, row
heights that wander all over ... utterly unusable trash.

So now I'm wondering if the problem charts in this case were created in an earlier version
of Office (where Word tables as OLE objects worked fairly well). On editing them in the
current version, they're updated to the "new, improved" version (or in plain English,
they're run through the meat grinder and handed back into PPT ready for the trash).
 
C

Cindy M.

Hi Steve,
So now I'm wondering if the problem charts in this case were created in an earlier version
of Office (where Word tables as OLE objects worked fairly well). On editing them in the
current version, they're updated to the "new, improved" version (or in plain English,
they're run through the meat grinder and handed back into PPT ready for the trash).
Good question, and one JS is supposed to be researching :)

Cindy Meister
 
J

JS

Hi Cindy and Steve:
I have not forgotten this. I've tracked the major source of the PPT files
with embedded word tables - its in Rio; next step is to find someone there
who will talk to me. I will let you know.
Steve, on another note and this may not have anything to do with this: when
manipulating embedded excel sheets in PPT, they have resized, usually
cutting out columns to the right - I read somewhere that this has to do with
the resolution of the screen, not the printer driver, could this be it?
Rgds, JS
 
C

Cindy M.

Hi Js,
on another note and this may not have anything to do with this: when
manipulating embedded excel sheets in PPT, they have resized, usually
cutting out columns to the right - I read somewhere that this has to do with
the resolution of the screen, not the printer driver, could this be it?
In Word - for what it's worth - this is the print driver and not the screen
resolution. But the behavior was changed in Word 2003.

Cindy Meister
 
S

Steve Rindsberg

Hi Cindy and Steve:
I have not forgotten this. I've tracked the major source of the PPT files
with embedded word tables - its in Rio; next step is to find someone there
who will talk to me. I will let you know.

I think a personal visit may be necessary. With an assistant in tow. said:
Steve, on another note and this may not have anything to do with this: when
manipulating embedded excel sheets in PPT, they have resized, usually
cutting out columns to the right - I read somewhere that this has to do with
the resolution of the screen, not the printer driver, could this be it?

Seems to be more to do with the specific Windows and PPT/Excel versions, or at
least as near as a couple of us could tell. Have a look here:

Excel info cut off or cropped when pasted into PowerPoint
http://www.pptfaq.com/FAQ00068.htm
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top