dcsimg
Results 1 to 10 of 10

Thread: Linking powerpoint text to a VSTO add in

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2018
    Posts
    5

    Linking powerpoint text to a VSTO add in

    Greetings,

    I have created a VSTO add in for powerpoint. I want to be able to take a selection of text on an existing powerpoint and copy it to my Add in text box. Can someone pleased help me as I cannot figure out the code to for the text in the already created powerpoint.

    Here is my vision: Open a powerpoint made by someone else. Make a selection of desired text I want to copy from the powerpoint. Click a button on the ribbon and have the text from the powerpoint copied to a text box in my VSTO add in.

    Any help would be great as I know very little about programming. Thank you very much for your time.

    Very Respectfully,

    Josh

  2. #2
    PowerPoster
    Join Date
    Oct 2008
    Location
    Midwest Region, United States
    Posts
    3,545

    Re: Linking powerpoint text to a VSTO add in

    I'm confused. If you're selecting the text manually, why do you need code to copy it? Please explain more fully.

  3. #3

    Thread Starter
    New Member
    Join Date
    Nov 2018
    Posts
    5

    Re: Linking powerpoint text to a VSTO add in

    Quote Originally Posted by vbfbryce View Post
    I'm confused. If you're selecting the text manually, why do you need code to copy it? Please explain more fully.

    here is my idea:

    If my boss came in with a presentation and I have the same presentation on my computer. If my boss points out something that is important I want to be able to select the text that is important and make my own outline. I don't want to take the time to type the information out. I want to simply select the text on the powerpoint slide, click a button, and have the text that is selected on the powerpoint slide be copied to my new outline in my add-in.

    The idea is to get important information moved from a powerpoint slide to make an outline. The idea is to shorten the time it takes to make outlines from existing powerpoints by highlighting text and having it automatically copied to an outline. Basically saving the time it takes to type out outlines.

    If that does not make any sense I can visually show you with an illustration. I appreciate your time and help.

    Very Respectfully,

    Josh

  4. #4
    PowerPoster
    Join Date
    Dec 2004
    Posts
    23,870

    Re: Linking powerpoint text to a VSTO add in

    I want to be able to select the text that is important and make my own outline. I don't want to take the time to type the information out.
    i am sure it would be possible, but i can not give exact code as i do not have powerpoint, possibly something like
    Code:
    myaddin.textbox1.text = selection.textrange.text
    though that would be more likely to copy the entire text rather than the selected text, i would just look at ctrl C after selecting and ctrl V to paste into the addin

    someone who uses powerpoint may give some better code example to exactly what you want
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  5. #5

    Thread Starter
    New Member
    Join Date
    Nov 2018
    Posts
    5

    Re: Linking powerpoint text to a VSTO add in

    Thank you for the reply. Unfortunately, that did not work. How do I reference the PowerPoint slides in code? I can figure out how to copy and paste them but I cant figure out what code is needed to reference the selected text in the PowerPoint presentation. I attached a reference photo. I want the selection from the slide to be copied to the textbox on the right..but only the selected text. Name:  quick.jpg
Views: 34
Size:  9.0 KB

    Thank you very much for your time and help.

    Very Respectfully,

    Josh

  6. #6

    Thread Starter
    New Member
    Join Date
    Nov 2018
    Posts
    5

    Re: Linking powerpoint text to a VSTO add in

    Thank you for the reply. Unfortunately, that did not work. How do I reference the PowerPoint slides in code? I can figure out how to copy and paste them but I cant figure out what code is needed to reference the selected text in the PowerPoint presentation. I attached a reference photo. I want the selection from the slide to be copied to the textbox on the right..but only the selected text. Name:  quick.jpg
Views: 34
Size:  9.0 KB

    Thank you very much for your time and help.

    Very Respectfully,

    Josh
    Attached Images Attached Images  

  7. #7
    PowerPoster
    Join Date
    Oct 2008
    Location
    Midwest Region, United States
    Posts
    3,545

    Re: Linking powerpoint text to a VSTO add in

    Still don't understand exactly, but maybe something like this:

    Code:
    Sub getText()
        Dim activeShape As Shape
        Dim shp As Shape
        Dim pres As Presentation
        Dim sld As Slide
        
        Set pres = ActivePresentation
        Set sld = pres.Slides(1)   'change as needed
        
        If ActiveWindow.Selection.Type = ppSelectionShapes Then
            For Each shp In ActiveWindow.Selection.ShapeRange
                Set activeShape = shp
                Exit For
            Next
        End If
        
        activeShape.TextFrame2.TextRange.Copy
        
        sld.Shapes(3).TextFrame2.TextRange.Paste
        '*** I'm pasting the text to another textbox,
        '*** you'd need to change the destination
        
    End Sub

  8. #8

    Thread Starter
    New Member
    Join Date
    Nov 2018
    Posts
    5

    Re: Linking powerpoint text to a VSTO add in

    I tried to copy and paste this into my program but it did not work. The "ActivePresentation" and "Set sld"did not work. Do I need to upload a reference library or change setting in my visual studio to get these things to work? Thank you again for your time.

  9. #9
    PowerPoster
    Join Date
    Dec 2004
    Posts
    23,870

    Re: Linking powerpoint text to a VSTO add in

    Do I need to upload a reference library or change setting in my visual studio
    should not be needed if you are doing this within powerpoint
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  10. #10
    PowerPoster
    Join Date
    Oct 2008
    Location
    Midwest Region, United States
    Posts
    3,545

    Re: Linking powerpoint text to a VSTO add in

    Do I need to upload a reference library or change setting in my visual studio to get these things to work?
    As Pete states, if you're using the code within Powerpoint, no additional references are required. If you're doing it within Visual Studio, then, yes, you'd need a reference to the Powerpoint object library.

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width