Consulting

Results 1 to 6 of 6

Thread: Show alt text from a shape to others shape

  1. #1
    VBAX Regular
    Joined
    Apr 2018
    Posts
    6
    Location

    Question Show alt text from a shape to others shape

    Hi everyone

    I want when I click the object that have an alt text, the alt text will appear in the other shape's text frame

    and I got the code, here is the code

    Sub changeText(oshp As Shape)
        Dim osld As Slide
        Dim otxtR As TextRange
        Set osld = oshp.Parent
        Set otxtR = osld.Shapes("mendatar").TextFrame.TextRange
        otxtR = oshp.AlternativeText
    End Sub
    But, I want the alt text that I separated with new line (or other sign like semicolon, etc) will appear in other shape that different with alt before the separator

    Like this :
    Shape A have an alt text : "This is alt text ; This will appear in different shape"

    When I click Shape A, "This is alt text" will appear in Shape B, and "This will appear in different shape" will appear in shape C

    How to do that ?
    Thank you

  2. #2
    VBAX Wizard
    Joined
    Apr 2007
    Posts
    5,618
    Location
    I assumed a semi-colon as seperator, and B and C as the other shapes


    Option Explicit
    '   A to B and C
    '   alt text in A = "This is alt text ; This will appear in different shape"
    '   "This is alt text" to B
    '   "This will appear in different shape" to C
    
    Sub changeText(oShape As Shape)
        Dim s As String
        Dim i As Long
        
        s = oShape.AlternativeText
        i = InStr(s, ";")
            
        oShape.Parent.Shapes("B").TextFrame.TextRange.Text = Trim(Left(s, i - 1))
        oShape.Parent.Shapes("C").TextFrame.TextRange.Text = Trim(Right(s, Len(s) - i))
    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
    Apr 2018
    Posts
    6
    Location
    I'll try it, thanks

  4. #4
    VBAX Regular
    Joined
    Apr 2018
    Posts
    6
    Location
    Great, its work, thank you so much

  5. #5
    VBAX Regular
    Joined
    Apr 2018
    Posts
    6
    Location
    how to mark it to be solved ? i cant find it
    how to vote your reply ?

  6. #6
    VBAX Wizard
    Joined
    Apr 2007
    Posts
    5,618
    Location
    Above your first post is [Thread Tools], one of which [Mark Solved]

    To add to a user's rep, there's a Star lower left -- I think you need so many posts before you see it -- not sure, but thanks for the thought anyway
    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

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
  •