Consulting

Results 1 to 3 of 3

Thread: Inserting today's date on a slide

  1. #1
    VBAX Regular
    Joined
    Dec 2018
    Posts
    91
    Location

    Inserting today's date on a slide

    Hi John

    The way our template works, it uses the Footer filed in PowerPoint with a classification inserted. This stops the date being added using the Header & Footer tool.

    I got as far as a text box going onto the slide, but I can't get the date to appear in the next text box.
    I don't want the date to update, just to show today's date when the macro is used.

    Can you help? Thanks. Have a wonderful long weekend.


    HTML Code:
    Sub AddDate()
    Dim StickerText As StringDim Sld As Slide
    StickerText = "ppDateTimeHmm"
    Dim shp As Shape
    For Each Sld In ActiveWindow.Selection.SlideRange
        Set shp = Sld.Shapes.AddShape(Type:=msoShapeRectangle, _        Left:=26 * 28.3464567, Top:=0 * 28.3464567, Width:=80, Height:=26.6)
            shp.Name = "Dated"        shp.Line.visible = msoFalse        shp.Fill.ForeColor.RGB = RGB(255, 255, 255)        shp.TextFrame.TextRange.Font.Color.RGB = RGB(0, 0, 0)        shp.TextFrame.TextRange.Characters.Text = StickerText        shp.TextFrame.TextRange.Paragraphs.ParagraphFormat.Alignment = ppAlignCenter        shp.TextFrame.TextRange.Paragraphs.ParagraphFormat.SpaceBefore = 0        shp.TextFrame.TextRange.Paragraphs.ParagraphFormat.SpaceAfter = 0        shp.TextFrame2.VerticalAnchor = msoAnchorMiddle        shp.TextFrame2.TextRange.Font.Size = 10        shp.TextFrame2.TextRange.Font.Name = "Arial"        shp.Rotation = 0
    Next Sld
    End Sub

  2. #2
    VBAX Wizard
    Joined
    Apr 2007
    Posts
    6,645
    Location
    If I'm understanding correctly ...


    Option Explicit
    
    
    Sub AddDate()
        Dim oSlide As Slide
        Dim oShape As Shape
        For Each oSlide In ActiveWindow.Selection.SlideRange
            
            For Each oShape In oSlide.Shapes
                If oShape.Name = "Dated" Then
                    oShape.Delete
                    Exit For
                End If
            Next
            
            Set oShape = oSlide.Shapes.AddShape(Type:=msoShapeRectangle, Left:=26 * 28.3464567, Top:=0 * 28.3464567, Width:=80, Height:=26.6)
            
            With oShape
                .Name = "Dated"
                .Line.Visible = msoFalse
                .Fill.ForeColor.RGB = RGB(255, 255, 255)
                .TextFrame.TextRange.Font.Color.RGB = RGB(0, 0, 0)
                .TextFrame.TextRange.Characters.Text = Format(Now, "Short Date")
                .TextFrame.TextRange.Paragraphs.ParagraphFormat.Alignment = ppAlignCenter
                .TextFrame.TextRange.Paragraphs.ParagraphFormat.SpaceBefore = 0
                .TextFrame.TextRange.Paragraphs.ParagraphFormat.SpaceAfter = 0
                .TextFrame2.VerticalAnchor = msoAnchorMiddle
                .TextFrame2.TextRange.Font.Size = 10
                .TextFrame2.TextRange.Font.Name = "Arial"
                .Rotation = 0
            End With
        Next oSlide
    End Sub
    
    Paul

    ------------------------------------------------------------------------------------------------------------------------
    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s)
    (multiple files can be selected while holding Ctrl key) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  3. #3
    VBAX Regular
    Joined
    Dec 2018
    Posts
    91
    Location
    Perfect, thanks Paul

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •