in reply to Re: M$ Word ole hyperlink
in thread M$ Word ole hyperlink

Thanks for the help, but am getting this error when running your code.

Can't call method "Hyperlinks" on an undefined value at sharepoint.pl line 14.

Like the approach, but do you have an example word doc you're using, how is it finding the hyperlink tokens?
Thanks,
- 3dbc

Replies are listed 'Best First'.
Re^3: M$ Word ole hyperlink
by poj (Abbot) on Jan 31, 2017 at 18:15 UTC

    Are you sure the document in ->Open() exists ?

    The tokens must be hyperlinks not just text.

    poj

      I agree, it's probably in the ->Open(). This might help 3dbc debug it.

      my $doc = $MSWord->Documents->Open('C:/temp/hyper.docm') or die $!;

      As far as the document: my "hyper.docm" was just a very simple test document I created.

      This is text This is hyperlink. This is text this is another hyper.

      ... then on "hyperlink" and "another hyper", I used Word to create hyperlinks (to wherever), saved, and exited.

      If you trust me1 , you could run this script to replicate my .docm exactly.

      edit: footnote 1: trust is earned. if I haven't earned it, don't run that code; I won't be offended. In general, it's a bad idea to download and run binaries that you have no reason to trust.

      Yes, it exists.
      - 3dbc

        "Yes, it exists." Weird, not sure why it's not working for you.

        Here's an alternative to my base64-encoded .docm: I added the document creation to the Win32::OLE commands. I also was reminded that $! doesn't get set by Win32::OLE; instead, use Win32::OLE->LastError().

        When I run that exact code, this is what I get. How does it compare to your output for the same code?

        inside second C:\temp\hyper2.docx here 1 Win32::OLE=HASH(0x478c00) inside http://google.com/ 1 Win32::OLE=HASH(0x4788b8) inside http://www.perlmonks.o +rg/ 2 Win32::OLE=HASH(0x478d98) second http://duckduckgo.com/ 2 Win32::OLE=HASH(0x478c00) second http://www.perlmonks.o +rg/