7

How to add hotlink to QGIS? I saw this but had some problem. I want to open network location like \\fileserver\filefolder\file1.excel but it ends with error.

Edit: The network location is stored in a column of the table eg. URL column contains URL value for each attribute. Different row has different URL.

8
  • 2
    It would help if you could describe the error.
    – sgrieve
    Commented Sep 7, 2012 at 7:44
  • @sgrieve Unable to run command. I actually have stored the location in one of the column and I have used it has an expression.
    – kinkajou
    Commented Sep 7, 2012 at 8:19
  • 1
    Maybe you need to prefix it with file:// or local://, since it is not directly on one of your disks. I imagine dos batch commands will have trouble interpreting that though. Commented Sep 7, 2012 at 8:30
  • @lynxlynxlynx still same error :(
    – kinkajou
    Commented Sep 7, 2012 at 8:41
  • 1
    On what OS are you using QGIS?
    – gioman
    Commented Sep 7, 2012 at 8:46

2 Answers 2

8

This way it works for me on Windows and Qgis 1.8.0:

Create a point shapefile with a field url of type string. Add a point and fill the url field with

\\<host>\<path>\<file>.xls 

without any blanks or quotation marks unless you have blanks in folder and filenames. Don't forget to save the layer, end leave edit mode.

In the layers properties, create a new action of type Generic , name it open and add

cmd /c [% "url" %] 

as action.

Select the Action icon, move the mouse over the point and click to open the excel sheet. The Excel sheet should have the standard .xls extension.

7
  • tried it but my path has space i.e. my file name has space "test test12.xls" it opens a command window and nothing happens
    – kinkajou
    Commented Sep 7, 2012 at 12:00
  • 2
    It might work if you put the whole path inside quotes. Just guessing though.
    – Rayner
    Commented Sep 7, 2012 at 12:33
  • 1
    Just tested: "\\fileserver\filefolder\file 1.xls" (with the quotation marks!) in the shapefile field works.
    – AndreJ
    Commented Sep 7, 2012 at 12:35
  • Glad I could help. Please vote my comment up if you think it was useful.
    – Rayner
    Commented Sep 7, 2012 at 16:45
  • @Rayner its helpful but my url is one of the column of table
    – kinkajou
    Commented Sep 9, 2012 at 9:47
2

I'd use python. After reading a blog post from Tim Sutton at linfiniti [1] I learned you can use python in actions:

eg something along those lines:

from pywin32.client import Dispatch
xl = Dispatch('Excel.Application')
wb = xl.Workbooks.Open('C:\\Documents and Settings\\GradeBook.xls')

taken from another post [2]

[1] http://linfiniti.com/2012/03/a-python-layer-action-to-open-a-wikipedia-page-in-qgis/

[2] https://stackoverflow.com/questions/247724/how-can-i-launch-an-instance-of-an-application-using-python

1
  • 1
    I don't know if it is excel or pdf as I have mentioned in the question it can be pdf or any other file too. I use it with mapinfo currently. It's easy in Mapinfo but I am not able to find this feature in Qgis easy.
    – kinkajou
    Commented Sep 10, 2012 at 1:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.