Home

Cardbox Talk

 

CardboxForumsCardbox Talk > "linking to local files"

linking to local files

How do you link to local files

Current user: [none]
Register / Log In · Help

Posted By Post

noldus

25-Sep-2007 10:30

Hello i need some help.

Is it possible to link to a local file or a file on the server in cardbox like you link to a webpage?
if so how can it be done??

Thanks for the Help

Dennis

Mary Doyle (DAF)

25-Sep-2007 11:28

Dennis

We use 2 methods

1.
Use file:// instead of http://
followed by the path for the local file e.g.
file://c:\docs\test.doc
You can then just click on the name in the Cardbox field and it will open.

If you use "file://" as the caption for the relevant field you don't have to
type file:// each time in the field, just the path of the file.

2.
Alternatively put the path of the file in the field (c:\docs\test.doc), without using file://and run a macro:

x = Fields("rf") ' rf is the field containing the path to the file
Launch x
This runs the file in the RF field.

Hope this helps.

Mary

cardboss

25-Sep-2007 12:38

To find about more about the file: method, open the Cardbox help and search for "file links". (DO type the quotation marks as part of your search request).

noldus

25-Sep-2007 13:28

i tried the 1st method which wont work,
i also tried it the way the help file says me still no succes the text just wont become a clickable link

Mary Doyle

25-Sep-2007 18:00

Hi Dennis,

I am afraid you may need to check with Cardbox Support to see why it won't work. I have tested both methods again at home and both work fine for me. I frequently use Cardbox to open files or launch other programs etc on my computer. If you are launching a program with parameters it is a little more complicated but if you need that I can tell you how (not something I worked out for myself, I have to confess - grateful acknowledgement to Martin in Cardbox Support).

Re: Method 1
If I have a field with the file name: c:\docs\test.doc and I add file: or file:// in front of it the text changes to blue and clicking on it will open the file. There is one possible reason your file won't open, i.e. if you have spaces in the file name. In that case only the text as far as the space will be connected to "file:". For that reason I tend not to leave spaces in filenames. I use upper case for the first letter of each word in the filename to help me read the name. If you want to retain the spaces you could use %20 to represent the space when typing the filename in the Cardbox field e.g. c:\docs\test 1.doc would become c:\docs\test%201.doc. I have tried this just now and it works.

The 2nd method I described also works fine for me i.e.
Field RF contains the text c:\docs\test.doc (no quotes)
Text of macro called: Open file
x = Fields("rf")
Launch x

The 2nd method works for me even if there is a space in the filename. For both methods you must have the full path to the file in the relevant field.

Maybe someone else can suggest why these methods are not working for you.

Mary

Charles Welling

26-Sep-2007 08:36

Dennis, if your link does not turn into a clickable one even when everything you typed is correct, then perhaps you haven't installed a recent enough version of Cardbox. Check if you have build 4217 or later. Older builds do not support the use of "file://".

If however the link is clickable, and the path\filename is correct, but the file still doesn't open, then check if the file type (look at the extension) has a programme attached to it.
"Doc" will generally be opened by Word, "xls" by Excel etc. but if you link to a file that is unknown to Windows, then Windows cannot determine what programme to use to open the file.
You can use Windows Explorer to attach a programme to a file type. Choose Tools, Folder options, File type. The rest speaks for itself.

Charles

Paul Irvine

26-Sep-2007 08:50

Make sure you set the 'Safety level' to Completely Trusted otherwise the file:// prefix is treated as text rather than as a link

Martin Collis

10-Dec-2007 11:33

I have exactly the same problem.

I have prefaced the field with FILE://

Clicking on it does nothing.

We have build 4251.

Is the fact the field defining the complete file name+location is indexed rather than just text relevant?

As the field is indexed it is already a different colour and does not change when you click on it.

Any ideas would be appreciated

bert

10-Dec-2007 12:49

Hi,
fille:// If there is a space in a filename: replace it by %20.
Perhaps that can solve your problem?
(my documents is then my%20documents)
Regards
Bert Stortenbeker

cardboss

10-Dec-2007 23:58

Since you have a support subscription, I suggest that you email us a screenshot so that we can see exactly what you mean.

When emailing, it would also help if you could confirm:

1. Whether the cursor changes shape when you move the mouse onto the "file:" prefix [prior to clicking on it].

2. What safety level the database has been opened with: you can discover this from Window > Properties.

This way we won't have to bombard everyone with every step in the process of resolving this problem. Once it has been resolved, we can always post a final message on here so that the solution is available as a reference in the future.

Bert, I think that failing to replace a space with "%20" would not lead to nothing happening, but to an error message appearing because the truncated filename ("my", in your example) couldn't be found.

Cardbox Support

R. Woodhouse

16-Mar-2008 13:53

I have tried these solutions - the first works but the second causes a runtime error 'file not recognised', error character 1 in line 2. I would prefer to use this second method linking the macro to a button, which seem a more elegant solution.

I have two further preferences:

1) For my purpose, it would be preferable to use a relative rather than an absolute hypelrink reference so the database is portable between computers. I cannot make this work.

2) It would be nice to link to a bookmark within the specified Word document. This will avoid the need to break up the Word documents into separate files for each reference.

Any advice would be much appreciated
Robert

cardboss

17-Mar-2008 14:23

Robert, Could you let us know what command you are launching? If, instead of

x = Fields("rf") ' rf is the field containing the path to the file
Launch x

you say

x = Fields("rf") ' rf is the field containing the path to the file
MsgBox "<" & x & ">"

what is the message that appears on the screen? (You may be able to copy the message to the clipboard with Ctrl+C).

Unlike HTML files, Word files can't (as far as I know) be referred to by names that specify a bookmark name as well as the filename.

R. Woodhouse

17-Mar-2008 21:52

The message says "the system cannot find the file specified (80070002). Position in the macro line 2, character 1."

The macro is

x=fileds("RF")
Launch x

The filename in field RF for the macro is:
F:\My%20Documents\Consulting\FAA\IFPP%20WGOW%20meeting%20Montreal%2008\Downloaded%20WPs\WPs\WP.1.doc

The filename in another field (which works when clicked) is exactly the same but with "FILE:" in its caption.

You can see from the file spec why I want to use relative addressing!

Hope this helps diagnsis,
Robert

bert

17-Mar-2008 23:21

Robert,
The solution is easy:
- Double click on a filename in a field with "file:" caption: you have to replace any space for %20.
- Launching a file by a macro you must NOT replace any space by %20.
Cardboss wrote already something about it.

For launching in macro a file: If there is a space in a path or filename you have to add a quote before the path+filename and after it. If there is no space in path & filename, it will give no problem.

So, your macro shoulde be:
x=replace(fields("RF"),"%20", " ") 'replace %20 to a space
Launch """" & x & """" 'launch the file without %20 and enclosed in quotes.

For testing: If a path & file name works on the windows startmenu option "RUN", it also will work with the launch command in a Cardbox macro (enclosed between quotes).

Regards
Bert

R. Woodhouse

18-Mar-2008 01:44

Dear Bert,

Success at last, but I am still a bit confused. The problem turned out to be the location of the quote marks. I placed them around the path/filename in the field RF, and then

x=Fields("RF")
MsgBox "<" & x & ">"
Launch x

opened the file corectly, showing the file path in the message box before opening the document. I tried various other combinations of the " locations but could not find another that worked.

So, part 1 of the problem is fixed, next is making it work with a relative rather than an absolute reference.

Robert

bert

18-Mar-2008 08:04

Dear Robert,
I understand that you only want store the last part of a path+document.
Something like [different locations]"\files\abc.doc". For launching a file of course you have to tell Windows the missing part.
In a macro there possibilities to substitute [different locations]:
- Place a file called docpath.txt with in it the path to your documents (the substitution for [different locations]) on a place that is on any machine: c:\ or "c:\documents en settings". Read that file first by your macro ad add the content to your launch command.

Then in Word finding a bookmark: It is possible to make a Cardbox macro to open a doc, then finding a bookmark in Word. You have of course to know the name of that bookmark then (place it in a separate field) and of course, the path+file name of the document.
In that case I think it is smarter to macro first a Wordobject, then open the file using the Word object, then find the bookmark in that document. If you are not familiar with scripting : in the Cardbox Help are very useful books suggested for learning this or try to find a consultant who will help you with it.

Kind regards
bert

Charles Welling

18-Mar-2008 10:04

Robert, it is still not quite clear to me exactly why you want to use relative filenames. So far you have given two reasons: the databases must be portable and your pathnames are very long and complicated.
As far as the first reason is concerned: if you want to access documents from another computer than your own, these documents must be on a server or on any other shared drive. In that case I'd use sharenames or mapped network drives to shorten the whole path to "X:" or "Z:" or whatever. This works fine as long as you have a very limited number of paths.

But I guess that the real problem is that you have quite a few different folders in which you have stored your documents. Cardbox would have to guess, simply by looking at the file name, where your document is. This can be done if you use structured file names. Suppose you have the following paths:
"My Documents\Concepts\Initial"
"My Documents\Concepts\Approved"
"My Documents\Final\Planned"
"My Documents\Final\Executed"

As "My Documents" applies to all files, you can simply make the macro add this at all times. Now let's call the folder Concepts "A" and Final "B". For easy remembering you could even add this to the folder name, e.g. "Concepts (A)", "Final (B)".
The folder Initial is referred to as "A" again, Approved = "B", Planned "C", and Executed = "E". So, documents in the first folder are in the path "AA", the second is "AB", the third is "BA" and the fourth is "BB".
Prefix these strings to your file names. A document called "Secret.doc" in Concepts\Initial would then become "AA-Secret.doc", the same in Final\Executed becomes "BB-Secret.doc".
Have your macro look at the first part of the file name (anything up to "-") and substitute the string thus found for the path, before opening it.

Alternatively, you can keep using the absolute paths but use GetOpenFilenames to have a macro type it for you.

R. Woodhouse

20-Mar-2008 01:06

Thank you Cardboss, Chares, Bert,

I now have the relative file names macro working nicely. I have structured the files below the Cardbox Fil/Fmt directory in the sequence of the main divisions and sub-divisions fo the material to be indexed, thus makng the package portable.

For Cardboss: I am lacking the knowledge and skills to develop macro further to lead to bookmarks in Word for the final version. I sent a request for advice re assistance and consultants to Support@cardbox this afternoon together with the initial project plan, and hope this has reached you.

Thanks to all,
Robert

Quick Reply

Please log in or register before trying to post a reply.

 
© 2010 Cardbox Software Limited   Home