Can I hyperlink to a MS Word bookmark?

GaryDGaryD Member Posts: 66
edited 2010-09-27 in NAV Tips & Tricks
Hello, we've got NAV 5.1 with SQL Server 2005. We're able to open a Microsoft Word document using a Hyperlink in NAV like this:
HYPERLINK('file:///c:\tmp\doc1.docx');
This also works:
HYPERLINK('c:\tmp\doc1.docx');
However, what we want is to be able to open up the document to a certain point where we've put a bookmark. After creating the bookmark called "test2" in Word, I tried the following code in NAV:
HYPERLINK('file:///c:\tmp\doc1.docx#test2');
and get the error:
You tried to hyperlink to this target:
file:///c:\tmp\doc1.docx#test2

Do you want to place that hyperlink target on the clipboard?

Is it not possible to open a Word document to a particular bookmark?

Thanks!

Answers

  • SavatageSavatage Member Posts: 7,142
    I don't have any personal knowledge - but perhaps you can find something to help you here:
    http://msdn.microsoft.com/en-US/library/5ykkex00(v=VS.80).aspx
  • GaryDGaryD Member Posts: 66
    Thanks but the bookmark is not the issue. We've created the bookmarks directly in the Word document. I just need a way for NAV to open the document to the topic (bookmark) we want but that seems to not be possible using Hyperlink.
  • GaryDGaryD Member Posts: 66
    Since it seems that this may not be possible using the Hyperlink function, I looked into Word automation and was able to do what I wanted with that. FYI, here's what I did, as a test, after creating a bookmark called "Test1" in a Word document:
    - create the needed automation objects: application, document, and bookmark
    - open the document then go to the bookmark

    Here's the pertinent code:
    WDoc := WApp.Documents.Open(FilePath);
    BK := 'Test1';
    WSBookmarks := WDoc.Bookmarks;
    WSBookmark := WDoc.Bookmarks.Item(BK);
    WSBookmark.Select;

    Thanks!
  • SavatageSavatage Member Posts: 7,142
    Perhaps this belongs in the tips & tricks section!
  • krikikriki Member, Moderator Posts: 9,112
    [Topic moved from 'NAV/Navision Classic Client' forum to 'NAV Tips & Tricks' forum]
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • UltramayankUltramayank Member Posts: 28
    The Hyperlink you have specified has syntax error
    it should be
    file:///c:/tmp/doc1.docx
    instead of
    file:///c:\tmp\doc1.docx

    Try this and let us know if it helped!!
    Mayank Bhardwaj
    Visit My Blog at
    http://extremeengineers.net/
  • SavatageSavatage Member Posts: 7,142
    GaryD wrote:
    , I looked into Word automation and was able to do what I wanted with that.

    He mentions he got what he needed already.
    It's also been marked as solved.
Sign In or Register to comment.