Change PowerPoint table font size from Access VBA?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • frogman123
    New Member
    • Apr 2013
    • 4

    Change PowerPoint table font size from Access VBA?

    Hello - trying to change PowerPoint (PP) table font size from Access VBA?

    My code creates a new PP presentation and applies a user selectable PP template. The code also creates a table based on Access data parameters. I am able to format the PP table boarders and fill .... just not the font size.

    Partial code below:
    ...
    Code:
    'POWERPOINT
    Dim pptObj As PowerPoint.Application
    Dim pptPres As PowerPoint.Presentation
    Dim pptSlide As Slide
    ...
    'Create a new file from an existing PowerPoint template
    Set fd = Application.FileDialog(msoFileDialogOpen) 'Open dialog to ask user to select PowerPoint template
    With fd
        .Show
        pptfile = .SelectedItems(1)
    End With
    Set pptObj = CreateObject("PowerPoint.Application")
    With pptObj
        .Visible = True
    End With
    Set pptPres = pptObj.Presentations.Add
    ...
    lngX = 1
    lngY = 1
    lngShapeID = 2
    With pptPres '1st With Statement
        With .Slides.Add(pptPres.Slides.Count + 1, ppLayoutTitle) '2nd Withstatement
            .ApplyTemplate (pptfile) 'apply powerpoint template file selected by user
            .Shapes.AddTable (ABSFindRecordCount + COMMFindRecordCount + InstrumFindRecordCount + MDIOCFindRecordCount + RangesFindRecordCount + SBSFindRecordCount + TSSFindRecordCount + 1), 6, 3, 90, 300, 60 'rows+header, columns,horizontal center, vertical center, width, height
    lngX = 1
    lngY = 1
    lngShapeID = 2
    
           'Format table columns
           lngShapeID = lngShapeID + 1
           With .Shapes(lngShapeID).Table '3rd With Statement
                .Columns(1).Width = 187
                .Columns(2).Width = 85
                .Columns(3).Width = 85
                .Columns(4).Width = 85
                .Columns(5).Width = 85
                .Columns(6).Width = 187
                
                'format table, no fill, black boarder
                .ApplyStyle ("{5940675A-B579-460E-94D1-54222C63F5DA}")
    ...


    Thanks, in advance, for any help!!
    Last edited by Rabbit; Apr 17 '13, 05:36 AM. Reason: Please use code tags when posting code.
  • frogman123
    New Member
    • Apr 2013
    • 4

    #2
    Ok, figured it out. following the bottom of my code above I have code that writes the table header out. Just needed to add two lines after writing value. The two lines change size to 12pt and then make it bold. Has to be done table cell by cell. Here is the code:


    Code:
    ...
                'Write table header from Access table
                lngX = 1
                lngY = 1
                RSpptblHeader.MoveFirst
                While Not RSpptblHeader.EOF
                    .Cell(lngY, lngX).Shape.TextFrame.TextRange.Text = RSpptblHeader.Fields("Header").Value
                    .Cell(lngY, lngX).Shape.TextFrame.TextRange.Font.Size = 12 '12pt font
                    .Cell(lngY, lngX).Shape.TextFrame.TextRange.Font.Bold = msoTrue 'make it bold
                    RSpptblHeader.MoveNext
                    lngX = lngX + 1
                Wend
    
    
    ...

    Comment

    Working...