none
System.Runtime.InteropServices.COMException PowerPoint couldn't create a hyperlink RRS feed

  • Question

  • I have an Office COM add in written in C# that uses hyperlinks in power point to display a place holder for some data, and store the data as the address like this: 

    string text = tagLoc.Tag.toText();
    string toDisplay = tagLoc.Tag.toDisplay(BaseTag.TAG_DISPLAY_LINK);
    //escape the link, office has a tendancy of manglining the data if not escaped
    text = Uri.EscapeDataString(text);
    tagLoc.TagTextRange.Text = toDisplay;
    tagLoc.TagTextRange.ActionSettings[Microsoft.Office.Interop.PowerPoint.PpMouseActivation.ppMouseClick].
    Action = PpActionType.ppActionHyperlink;
    
    tagLoc.TagTextRange.ActionSettings[Microsoft.Office.Interop.PowerPoint.PpMouseActivation.ppMouseClick].
    Hyperlink.Address = "wrdp://" + text;
    tagLoc.TagTextRange is a Microsoft.Office.Interop.PowerPoint.TextRange

    This method of doing things has been working fine for the most part, but when I try to set the hyperlink address to 

    "wrdp://%3Cwr%3Aquery%20select%3D'DECLARE%20%40qdate%20as%20datetime%26%23x0D%3B%26%23x0A%3Bset%20%40qdate%20%3D%20%26apos%3B2016-10-01%26apos%3B%26%23x0D%3B%26%23x0A%3B%26%23x0D%3B%26%23x0A%3BDECLARE%20%40pqsdate%20as%20datetime%26%23x0D%3B%26%23x0A%3BDECLARE%20%40pqedate%20as%20datetime%26%23x0D%3B%26%23x0A%3BDECLARE%20%40cqsdate%20as%20datetime%26%23x0D%3B%26%23x0A%3BDECLARE%20%40cqedate%20as%20datetime%26%23x0D%3B%26%23x0A%3B%26%23x0D%3B%26%23x0A%3Bset%20%40cqedate%20%3D%20dateadd(dd%2C-1%2C%26apos%3B2016-10-01%26apos%3B)%26%23x0D%3B%26%23x0A%3Bset%20%40cqsdate%20%3D%20dateadd(mm%2C-3%2C%26apos%3B2016-10-01%26apos%3B)%26%23x0D%3B%26%23x0A%3Bset%20%40pqedate%20%3D%20dateadd(dd%2C-1%2C%40cqsdate)%26%23x0D%3B%26%23x0A%3Bset%20%40pqsdate%20%3D%20dateadd(mm%2C-3%2C%40cqsdate)%26%23x0D%3B%26%23x0A%3B%26%23x0D%3B%26%23x0A%3BSELECT%26%23x0D%3B%26%23x0A%3B%26%23x0D%3B%26%23x0A%3Bcount(CASE%20WHEN%20orderdate%20%26lt%3B%20%40pqsdate%20and%20requireddate%20%26gt%3B%3D%20%40pqsdate%20THEN%201%20END)%20as%20headcountPrevQS%2C%26%23x0D%3B%26%23x0A%3Bcount(CASE%20WHEN%20orderdate%20%26lt%3B%20%40cqsdate%20and%20requireddate%20%26gt%3B%3D%20%40cqsdate%20THEN%201%20END)%20as%20headcountCurQS%2C%26%23x0D%3B%26%23x0A%3Bcount(CASE%20WHEN%20orderdate%20between%20%40pqsdate%20and%20%40pqedate%20THEN%201%20END)%20as%20startersPrevQ%2C%26%23x0D%3B%26%23x0A%3Bcount(CASE%20WHEN%20orderdate%20between%20%40cqsdate%20and%20%40cqedate%20THEN%201%20END)%20as%20startersCurQ%2C%26%23x0D%3B%26%23x0A%3Bcount(CASE%20WHEN%20orderdate%20%26lt%3B%3D%20%40pqedate%20and%20requireddate%20%26gt%3B%3D%20%40pqsdate%20THEN%201%20END)%20as%20headcountActivePrevQ%2C%26%23x0D%3B%26%23x0A%3Bcount(CASE%20WHEN%20orderdate%20%26lt%3B%3D%20%40cqedate%20and%20requireddate%20%26gt%3B%3D%20%40cqsdate%20THEN%201%20END)%20as%20headcountActiveCurQ%2C%26%23x0D%3B%26%23x0A%3Bcount(CASE%20WHEN%20requireddate%20between%20%40pqsdate%20and%20%40pqedate%20THEN%201%20END)%20as%20finishersPrevQ%2C%26%23x0D%3B%26%23x0A%3Bcount(CASE%20WHEN%20requireddate%20between%20%40cqsdate%20and%20%40cqedate%20THEN%201%20END)%20as%20finishersCurQ%2C%26%23x0D%3B%26%23x0A%3Bcount(CASE%20WHEN%20orderdate%20%26lt%3B%3D%20%40pqedate%20and%20requireddate%20%26gt%3B%20%40pqedate%20THEN%201%20END)%20as%20headountPrevQE%2C%26%23x0D%3B%26%23x0A%3Bcount(CASE%20WHEN%20orderdate%20%26lt%3B%3D%20%40cqedate%20and%20requireddate%20%26gt%3B%20%40cqedate%20THEN%201%20END)%20as%20headountCurQE%2C%26%23x0D%3B%26%23x0A%3Bcount(CASE%20WHEN%20orderdate%20%26lt%3B%3D%20%40pqedate%20and%20requireddate%20%26gt%3B%3D%20%40pqsdate%20and%20cu.country%20%3D%20%26apos%3BUSA%26apos%3B%20THEN%201%20END)%20as%20agencyPrevQ%2C%26%23x0D%3B%26%23x0A%3Bcount(CASE%20WHEN%20orderdate%20%26lt%3B%3D%20%40pqedate%20and%20requireddate%20%26gt%3B%3D%20%40pqsdate%20and%20cu.country%20%3D%20%26apos%3BFrance%26apos%3B%20THEN%201%20END)%20as%20directPrevQ%2C%26%23x0D%3B%26%23x0A%3Bcount(CASE%20WHEN%20orderdate%20%26lt%3B%3D%20%40pqedate%20and%20requireddate%20%26gt%3B%3D%20%40pqsdate%20and%20cu.country%20%3D%20%26apos%3BUnited%20Kingdom%26apos%3B%20THEN%201%20END)%20as%20managedPrevQ%2C%26%23x0D%3B%26%23x0A%3Bcount(CASE%20WHEN%20orderdate%20%26lt%3B%3D%20%40pqedate%20and%20requireddate%20%26gt%3B%3D%20%40pqsdate%20and%20cu.country%20%3D%20%26apos%3BGermany%26apos%3B%20THEN%201%20END)%20as%20managedMigPrevQ%2C%26%23x0D%3B%26%23x0A%3BAVG(CASE%20WHEN%20orderdate%20%26lt%3B%3D%20%40pqedate%20and%20requireddate%20%26gt%3B%3D%20%40pqsdate%20THEN%20od.employeeID%20*%201.2%20END)%20as%20avgRatePrevQ%2C%26%23x0D%3B%26%23x0A%3Bcount(CASE%20WHEN%20orderdate%20%26lt%3B%3D%20%40cqedate%20and%20requireddate%20%26gt%3B%3D%20%40cqsdate%20and%20cu.country%20%3D%20%26apos%3BUSA%26apos%3B%20THEN%201%20END)%20as%20agencyCurQ%2C%26%23x0D%3B%26%23x0A%3Bcount(CASE%20WHEN%20orderdate%20%26lt%3B%3D%20%40cqedate%20and%20requireddate%20%26gt%3B%3D%20%40cqsdate%20and%20cu.country%20%3D%20%26apos%3BUnited%20Kingdom%26apos%3B%20THEN%201%20END)%20as%20directCurQ%2C%26%23x0D%3B%26%23x0A%3Bcount(CASE%20WHEN%20orderdate%20%26lt%3B%3D%20%40cqedate%20and%20requireddate%20%26gt%3B%3D%20%40cqsdate%20and%20cu.country%20like%20%26apos%3BFrance%26apos%3B%20THEN%201%20END)%20as%20managedCurQ%2C%26%23x0D%3B%26%23x0A%3Bcount(CASE%20WHEN%20orderdate%20%26lt%3B%3D%20%40cqedate%20and%20requireddate%20%26gt%3B%3D%20%40cqsdate%20and%20cu.country%20%3D%20%26apos%3BGermany%26apos%3B%20%20THEN%201%20END)%20as%20managedMigCurQ%2C%26%23x0D%3B%26%23x0A%3BAVG(CASE%20WHEN%20orderdate%20%26lt%3B%3D%20%40cqedate%20and%20requireddate%20%26gt%3B%3D%20%40cqsdate%20THEN%20od.employeeID%20*%201.2%20END)%20as%20avgRateCurQ%26%23x0D%3B%26%23x0A%3B%26%23x0D%3B%26%23x0A%3BFROM%26%23x0D%3B%26%23x0A%3B%26%23x0D%3B%26%23x0A%3BOrders%20od%20INNER%20JOIN%20Customers%20cu%20on%20od.customerid%20%3D%20cu.customerid%26%23x0D%3B%26%23x0A%3B%26%23x0D%3B%26%23x0A%3BWHERE%26%23x0D%3B%26%23x0A%3B%26%23x0D%3B%26%23x0A%3Bcu.country%20in%20(%26apos%3BUSA%26apos%3B%2C%26apos%3BUK%26apos%3B%2C%26apos%3BUnited%20Kingdom%26apos%3B%2C%26apos%3BGermany%26apos%3B%2C%26apos%3BFrance%26apos%3B)'%20var%3D'varName4'%20datasource%3D'MSSQL'%2F%3E"

    the exception in the title is thrown with no stack trace.

    I'm wondering what could possibly be causing this in this specific case. Could it just be the length of the string?

    Monday, March 6, 2017 10:52 PM

Answers

  • Hi Binz775,

    As you had mentioned above, you are not actually storing the link of any web page.

    and you are trying to save the data in the link.

    something like query string in Asp.net.

    I think that it is possible that you are trying to store much more data then it's capacity.

    try to store less data and make a test. if that work then we can say that the reason is length of data.

    if still you are getting the error then I suggest you to find a work around to store your data anywhere else.

    it's not a correct place to store data.

    it is possible that someone can try to read the data from URL.

    Regards

    Deepak


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by Matt Binsfeld Tuesday, September 19, 2017 9:47 PM
    Tuesday, March 21, 2017 8:16 AM
    Moderator

All replies

  • Hi Binz775,

    try to use code below.

    using ppt = Microsoft.Office.Interop.PowerPoint;
    
     private void button1_Click(object sender, EventArgs e)
            {
                
    
                ppt.Application pptApplication = new ppt.Application();
    
                ppt.Slide pptSlide;
                ppt.Presentation pptPresentation = pptApplication.Presentations.Add(MsoTriState.msoTrue);
                pptApplication.Visible = MsoTriState.msoTrue;
                pptSlide = pptPresentation.Slides.Add(1, ppt.PpSlideLayout.ppLayoutTitle);
    
                Microsoft.Office.Interop.PowerPoint.TextRange objText;
    
                objText = pptSlide.Shapes[2].TextFrame.TextRange;
                objText.Text = "Hello World";
                objText.ActionSettings[Microsoft.Office.Interop.PowerPoint.PpMouseActivation.ppMouseClick].Hyperlink.Address = "http://www.bing.com";
            }

    Regards

    Deepak


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, March 7, 2017 2:49 AM
    Moderator
  • Hi Deepak,

    That's what I'm doing, and in most cases it works fine. This has only ever been an issue in this one case. I'm wondering if the problem is caused by the length of the data I am puthing in the Hyperlink.Address?

    Also I am not actually using the Hyperlink to link to the web, but rather to store data for my application that needs to be associated with that text.

    Thanks,

    Matt

    Monday, March 20, 2017 8:34 PM
  • Hi Binz775,

    As you had mentioned above, you are not actually storing the link of any web page.

    and you are trying to save the data in the link.

    something like query string in Asp.net.

    I think that it is possible that you are trying to store much more data then it's capacity.

    try to store less data and make a test. if that work then we can say that the reason is length of data.

    if still you are getting the error then I suggest you to find a work around to store your data anywhere else.

    it's not a correct place to store data.

    it is possible that someone can try to read the data from URL.

    Regards

    Deepak


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by Matt Binsfeld Tuesday, September 19, 2017 9:47 PM
    Tuesday, March 21, 2017 8:16 AM
    Moderator