table loose formatting when applying template - VBA

S

Savan Gandhi

Hi,
I have a table in my slide. The results of manually applying a template are different from that when applied using VBA method: _presentation.applytemplate(). The font size is maintained when applying a template manually. It gets lost thru' VBA. The font size reduces, in my case from 28 to 18.

I have a work around:
If sh.Type = msoTable Then
Dim shr As PowerPoint.ShapeRange = sh.Ungroup
shr.Group()
End If
I run above code before: _presentation.applytemplate(). The formatting is preserved but the table gets converted into a group of rectangular textbox. It does not behave anymore like a table.

How can preserve table's formatting with _presentation.applytemplate() ?

Regards,
Savan
 
S

Savan Gandhi

The ppt has only one master (slidemaster + titlemaster). It is a simple ppt
with 4 slides (all with text data). The 4th slide contains table.

Regards,
Savan
 
S

Savan Gandhi

On the same note, I would also like to question:
Will these two operations produce the same result?

1. InsertPptSlideX(_presentation, _sourceSlide) // this copies source
slide along with design into destination ppt (_presentation)
_presentation.applytemplate(x) // apply template
to _presentation

2. _presentation.applytemplate(x)
InsertPptSlideY(_presentation, _sourceSlide) // this copies source
slide WITHOUTdesign into destination ppt

function InsertPptSlideX() //assume all variable are declared
{
'Copy from source, paste in destination
sldSource.Copy()
_presentation.Slides.Paste(slideIndex)
sldInserted = _presentation.Slides(slideIndex)
sldInserted.Design = sldSource.Design
sldInserted.ColorScheme = sldSource.ColorScheme
sldInserted.DisplayMasterShapes = sldSource.DisplayMasterShapes
'Copy the background
CopyBackground(sldSource, sldInserted)
}

function CopyBackground(ByVal sldSource As Slide, ByVal sldDest As Slide)
{
log.Debug("Entering CopyBackground()")

If sldSource.FollowMasterBackground = msoFalse Then
sldDest.FollowMasterBackground = msoFalse
sldDest.Background.Fill.ForeColor.RGB = _
sldSource.Background.Fill.ForeColor.RGB
Else
Exit Sub
End If

Select Case sldSource.Background.Fill.Type
Case msoFillGradient
Select Case sldSource.Background.Fill.GradientColorType
Case msoGradientOneColor
Call sldDest.Background.Fill.OneColorGradient( _
sldSource.Background.Fill.GradientStyle, _
sldSource.Background.Fill.GradientVariant, _
sldSource.Background.Fill.GradientDegree)
Exit Sub
Case msoGradientTwoColors
log.Debug("Gradient Two Colors")
sldDest.Background.Fill.BackColor.RGB = _
sldSource.Background.Fill.BackColor.RGB
Call sldDest.Background.Fill.TwoColorGradient( _
sldSource.Background.Fill.GradientStyle, _
sldSource.Background.Fill.GradientVariant)
Exit Sub
Case msoGradientPresetColors
log.Debug("Gradient Preset Color")
Call sldDest.Background.Fill.PresetGradient( _
sldSource.Background.Fill.GradientStyle,
_
sldSource.Background.Fill.GradientVariant,
_
sldSource.Background.Fill.PresetGradientType)
sldDest.Background.Fill.BackColor.RGB = _
sldSource.Background.Fill.BackColor.RGB
End Select
Case msoFillPicture, msoFillTextured
'Save bg as image and insert on new slide
Dim strBgImage As String
Dim blnFooterVisible As MsoTriState ' Boolean

blnFooterVisible = sldSource.HeadersFooters.Footer.Visible
If CBool(blnFooterVisible) Then
sldSource.HeadersFooters.Footer.Visible = msoFalse
strBgImage = _pptApplication.Path & "\tmp_bg.jpg"
Call SaveBackgroundImage(sldSource, strBgImage)
Call SetBgImage(sldDest, strBgImage)
If blnFooterVisible <>
sldSource.HeadersFooters.Footer.Visible Then
'we hidded the footer to generate the image, now we
restore it
sldSource.HeadersFooters.Footer.Visible = msoTrue
End If
Case msoFillSolid
sldDest.Background.Fill.Solid()
'ForeColor was defined at the beginning of the sub
Case msoFillPatterned
sldDest.Background.Fill.Patterned(sldSource.Background.Fill.Pattern)
sldDest.Background.Fill.BackColor.RGB = _
sldSource.Background.Fill.BackColor.RGB
End Select

log.Debug("Exiting CopyBackground()")
} // end of copybackground()

If (1) and (2) above will produce same result, then what code do I need to
remove from function InsertPptSlideX() so that I can create function
InsertPptSlideY()?

Thanks,
Savan
 
S

Sam

I wanted to confirm that when we call
_presentation.applytemplate(templatefile), we are essentially copying ONLY
templatefile's designs in _presentation. I mean we can also do the same
thing by copying all designs from templatefile to _presentation.
(templatefilepresentation.designs collection) Please correct me if I am
wrong.

Regards,
Savan
 
S

Sam

Gentle reminder....

Sam said:
I wanted to confirm that when we call
_presentation.applytemplate(templatefile), we are essentially copying ONLY
templatefile's designs in _presentation. I mean we can also do the same
thing by copying all designs from templatefile to _presentation.
(templatefilepresentation.designs collection) Please correct me if I am
wrong.

Regards,
Savan
 
S

Sam

okay. Thanks Steve for reply.

Regards,
Savan
Steve Rindsberg said:
If you copy all designs from one file to another, you're appending the
designs
from the source file to those in the target file.

If you apply source file as a template, you DELETE any masters in the
target
presentation that aren't set to PRESERVE and add the masters from the
source
presentation.

Even this may vary between versions. It might be best to watch what
happens
when you do this manually or with bits of VBA code from within PPT.


-----------------------------------------
Steve Rindsberg, PPT MVP
PPT FAQ: www.pptfaq.com
PPTools: www.pptools.com
================================================
Live and in personable in the Help Center at PowerPoint Live
Sept 21-24, San Diego CA, USA
www.pptlive.com
 

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