Consulting

Results 1 to 3 of 3

Thread: Format Object

  1. #1
    VBAX Newbie
    Joined
    Jul 2018
    Posts
    2
    Location

    Format Object

    Hi Guys,

    I have the problem that I always run into an error on the last row of the following code.
    What I want to achieve is to left align the text in the textbox (per default it is centered).

    Thanks for your help.
    Best
    Mathias

    **************

    Dim rng As Range
    Dim rng2 As Range
    Dim PowerPointApp As Object
    Dim myPresentation As Object
    Dim mySlide As Object
    Dim myShape As Object








    'Copy Range from Excel
    Set rng = ThisWorkbook.ActiveSheet.Range("F4:F4")
    Set rng2 = ThisWorkbook.ActiveSheet.Range("E4:E4")


    'Create an Instance of PowerPoint


    'Is PowerPoint already opened?
    Set PowerPointApp = GetObject(class:="PowerPoint.Application")
    Set PowerPointApp = PowerPointApp.Presentations("Test.pptx")


    PowerPointApp.Slides.Range(1).Select


    'Add a slide to the Presentation
    Set mySlide = PowerPointApp.Slides(1).Duplicate()(1)


    'Copy Excel Range
    rng.Copy



    'Paste to PowerPoint and position
    mySlide.Shapes.PasteSpecial DataType:=7 '7 = ppPasteText
    Set myShape = mySlide.Shapes(mySlide.Shapes.Count)

    'Set position, size and format:
    myShape.Left = 26
    myShape.Top = 104
    myShape.Width = 312
    myShape.Height = 40
    myShape.Height = 40
    myShape.TextFrame2.TextRange.Font.Size = 8
    myShape.TextFrame2.TextRange.Font.Name = "Arial"
    myShape.TextFrame.TextRange.ParagraphFormat.Alignment = ppAlignLeft

  2. #2
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,726
    Location
    Excel doesn't understand ppAlignLeft

    Try

    myShape.TextFrame.TextRange.ParagraphFormat.Alignment = 1
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    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) / 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 Newbie
    Joined
    Jul 2018
    Posts
    2
    Location
    Thanks Paul, this is very helpful and works well!

Posting Permissions

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