none
microsoft powerpoint, find text in ppt and hyperlink it. RRS feed

  • Question

  • I have used the following code snippet

    of microsoft API powerpoint In That we want to find text in ppt and hyperlink it for that we are using regular expressions also

    for eg if the string is like 905678 and we are applying the regex of \d{2} then we are getting 3 groups

    we are using following method to find text in ppt

    TextRange range= textRange.Find(findText, 0, matchCase, matchWholeWord);

    after finding that word we are getting range of that we are passssing that to following method to hyperlink that

     static void AddHyperlink(ref TextRange textRange, string tagValue, string context)
            {
                // Create the cell action.
                PpMouseActivation mouseActivation = PpMouseActivation.ppMouseClick;
             
                var cellAction = textRange.ActionSettings[mouseActivation];

                cellAction.Action = PpActionType.ppActionHyperlink;
                cellAction.Hyperlink.Address = "javascript:selectItem('" + context + "|" + tagValue + "',42)";
                cellAction.Hyperlink.SubAddress = "";
                cellAction.Hyperlink.ScreenTip = "";
                cellAction.Hyperlink.TextToDisplay = tagValue;
               
            }

    but what is happening is it is only hyperlnking the 90 of string 905678.

    for you information: we are using vs2010 and ms office2010.  
    please help me to fix this Issue  waiting for your reply.

    Thursday, July 7, 2011 9:27 AM

Answers

  • Hello Navnit,

    The problem is: TextRange.Find " ...returns a TextRange object that represents the first text range where the text is found.", see http://msdn.microsoft.com/en-us/library/ff744247.aspx. I suggest that you create a new TextRange containing only "90" (or whatever) and setting a hyperlink for this TextRange. To create such a textRange, I'd use TextRange.Characters(n, n+2).Select.


    Regards from Belarus (GMT + 2),

    Andrei Smolin
    Add-in Express Team Leader
    Monday, July 18, 2011 10:10 AM

All replies

  • Hello,

    Do you pass "90" or "905678" to AddHyperlink?


    Regards from Belarus (GMT + 2),

    Andrei Smolin
    Add-in Express Team Leader
    Friday, July 8, 2011 9:46 AM
  • Hi Andrei

    We are passing 90 then 56 then 78 from the string 905678

    the above digits we are getting from regex from string 905678 which is in ppt

    then findtext =90;


    TextRange range= textRange.Find(findText, 0, matchCase, matchWholeWord);

    from above method we are getting range of the 90 that we are pssing to the above hyperlink function after that same for the 56 and 78
    but it is not hyperlinking the other two sets that is 56 and 78
    It is hyperlinking only 90 with the vale of 78( "javascript:selectItem('" + context + "|" + tagValue + "',42)";)

    Let me know if you need more information for the same

    waiting for your reply


    Navnit

    Monday, July 11, 2011 5:23 AM
  • Hello Navnit,

    The problem is: TextRange.Find " ...returns a TextRange object that represents the first text range where the text is found.", see http://msdn.microsoft.com/en-us/library/ff744247.aspx. I suggest that you create a new TextRange containing only "90" (or whatever) and setting a hyperlink for this TextRange. To create such a textRange, I'd use TextRange.Characters(n, n+2).Select.


    Regards from Belarus (GMT + 2),

    Andrei Smolin
    Add-in Express Team Leader
    Monday, July 18, 2011 10:10 AM