none
Generate hyperlink to file within Onenote RRS feed

  • Question

  • I need to create a onenote-page which contains a number of hyperlinks to files on the disk or perhaps network-share). The generating of the ON-page is no issue anymore, this will work coorectly. Even the list of files on a specific directory is no problem at all.

    My issue is generating a working hyperlink: I tried several pieces of code, but every time the same "error" will result in not creating a hyperlink. My current piece of code looks like this:

    sb.AppendLine(string.Format(string.Format("<ahref=\"onenote:Project%202.one#base-path={0}\">...</a>",
          Path.GetFullPath(filePaths[x]))));

    the output is < a href=\"onenote:Project%202.one#base-path=c:\\temp\\connectorLog.txt\">...< /a >\r\n"
     
    the last backslash after "connector.txt" is used for escaping the double quotes, but should not be part of the filename. So the only thing I can see in the ON-page, are three periods in plain text and no hyperlink is created,
     

    This all will be done by a custom made add-in
    Can somebody help me a little??

      

    • Edited by pkouwer Friday, December 27, 2013 9:42 AM
    Friday, December 27, 2013 7:50 AM

Answers

  • Hi,

    I try to reproduce your issue with the code below and there is a hyperlink in the result.

    StringBuilder sb = new StringBuilder();
          sb.AppendLine(string.Format(string.Format("<a href=\"onenote:Project%202.one#base-path={0}\">...</a>",
    Path.GetFullPath(@"C:\Users\Documents\test.txt"))));

    The output hyperlink is: onenote:Project%202.one#base-path=C:\Users\Documents\test.txt

    So I think your issue may be related to the Path.GetFullPath(filePaths[x]), you could check it.

    By the way, I think this issue is more related to C# development instead of Office Object Model. For more questions about C# development, I suggest you posting them in the C# development forum for more effective responses.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Monday, December 30, 2013 6:14 AM
    Moderator

All replies

  • Hello pkouwer,

    Did you try to specify a verbatim string without back slashes?

    You can read more about strings in the C# Programming Guide and C# Reference.

    Friday, December 27, 2013 4:53 PM
  • Hi,

    I try to reproduce your issue with the code below and there is a hyperlink in the result.

    StringBuilder sb = new StringBuilder();
          sb.AppendLine(string.Format(string.Format("<a href=\"onenote:Project%202.one#base-path={0}\">...</a>",
    Path.GetFullPath(@"C:\Users\Documents\test.txt"))));

    The output hyperlink is: onenote:Project%202.one#base-path=C:\Users\Documents\test.txt

    So I think your issue may be related to the Path.GetFullPath(filePaths[x]), you could check it.

    By the way, I think this issue is more related to C# development instead of Office Object Model. For more questions about C# development, I suggest you posting them in the C# development forum for more effective responses.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Monday, December 30, 2013 6:14 AM
    Moderator