Jump to content

Need help getting excel link to work


ahha
 Share

Recommended Posts

Okay I have tried all of these and all but one work. See code below.

;create excel hyperlinks.au3
#include <Excel.au3> ; Include the Excel collection

$oExcel = _ExcelBookNew(1);open up new book (Book1.xls) to play with - default is 3 sheets, Sheet1, Sheet2, Sheet3
MsgBox(0+262144,"","Let's continue?")

FileWriteLine("c:\test.txt", "This is a test text file.");put a test.txt create a test.txt file

_ExcelHyperlinkInsert($oExcel, "File directory", "c:\test.txt", "", 1, 1); works
_ExcelHyperlinkInsert($oExcel, "URL", "http://www.sun.com/", "", 2, 1)      ; works
_ExcelHyperlinkInsert($oExcel, "Link to another cell", "file:///C:\Book1.xls - Sheet2!A1", "", 3, 1); DOES NOT WORK 
;tried "Book1.xls - Sheet2!A1" - does not work
;tried "Sheet2!A1" - does not work

_ExcelHyperlinkInsert($oExcel, "New xls", "file:///C:\xxx.xls", "", 4, 1)
_ExcelHyperlinkInsert($oExcel, "email", "mailto:testing@test.com?subject=This is a test", "", 5, 1);works

MsgBox(0+262144,"","Exit?")
_ExcelBookClose($oExcel);don't save
Exit
Link to comment
Share on other sites

Try

_ExcelHyperlinkInsert($oExcel, "Link to another cell", "file:///C:\Book1.xls#Sheet2!A1", "", 3, 1)
Thank you - it works perfectly! Now the natural question, how did you know about the # as when I link manually it never showed that. Is there a reference somewhere on Excel functions?
Link to comment
Share on other sites

FYI this open a new copy of Book1.xls

_ExcelHyperlinkInsert($oExcel, "Link to another cell", "file:///C:\Book1.xls#Sheet2!A1", "", 3, 1)

This uses the existing copy of Book1.xls

_ExcelHyperlinkInsert($oExcel, "Link to another cell", "#Sheet2!A1", "", 3, 1)

Thanks for the hint above. Problem solved.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...