MacMusic  |  PcMusic  |  440 Software  |  440 Forums  |  440TV  |  Zicos
file
Search

Link From Document to Document On Your Mac

Wednesday October 25, 2023. 05:00 PM , from MacMost
There is no native functionality to link from inside one document to another. However, you can use a clever Shortcut to allow this. You can link from inside a Pages document to another Pages document, or to a Numbers file, or Numbers to Numbers, and so on.
Want to know more about how to use Shortcuts on your Mac?Check out this MacMost course!


Video Transcript: Hi, this is Gary with MacMost.com. Let me show you how to create links in your documents to other files on your Mac.
MacMost is brought to you thanks to a great group of more than 1000 supporters. Go to MacMost.com/patreon. There you can read more about it. Join us and get exclusive content and course discounts.
So one of the questions I get the most often is can you create link in a document, say a Pages document or a Numbers document, to another file. This could be useful in a number of situations. Unfortunately, you can't do it. Here I am in Pages and I can select some text and go to Format, Add Link and you can see I can add a link to a webpage, an email so I can generate a new email to a specific recipient, I can do a phone number so I can call on FaceTime, or a Bookmark inside the Pages document. But there isn't an option to link to another file. If you select webpage you get to enter a URL. It seems like you should be able to use File and then colon, slash slash, and then a path to a file and that should work but it doesn't!
Another thing that doesn't really work very well is if you generate a link using a shared iCloud File. Then that link usually opens up the file in the web app for Pages, Numbers, or Keynote. Not actually in those apps on your Mac. So none of those are good options. It looks like there is really no way to do this.
But, I did find one solution that, while not perfect, will work. That's to use Shortcuts. In Shortcuts you can create a new shortcut. One of the things that you can do is Open File. You can select that action there. You can click here where it says File and then you can select To File. So, for instance, under Projects I can select this file here. Open and if I run this shortcut it opens the file in Pages. So that works but it has several problems. One problem is that it has to specify the exact file to open. So if you want to do this once fine. But if you want to do this over and over again or have a list of ten files you're going to have to create ten different shortcuts, each one linking to the right file. If you try to feed in a path to this instead of specifying the exact file you run into all sorts of permissions problems. It won't work in the Documents folder for some reason but only in a subfolder. It gets very complex and hard to deal with using Open.
So instead of Open we're going to do an alternative. That's to use a shell script. So, there's Run Shell Script and we'll add that. Now we'll replace this sample here simply with the Terminal Command, Open. So this is just like running this in Terminal and then inside of quotes here we're going to put a path to the file. Now it's actually quite easy to get the path. If we go into the Finder here and find the File that we want, if we select it and then go to Edit notice where it says Copy, hold down the Option Key notice it says Copy as Pathname. The keyboard shortcut is simply Option Command C. So I'll copy the pathname. Now back here in the Shortcut right in-between those quotes I'll do Command V to paste. You can see it gives me the complete path. If I run this it will do the same thing. It just is using a slightly different technique. But the advantage is that each time we use it that we can feed something different into here. We'll find that really useful in a minute.
But before we do that let's get this to work as a link inside of a Pages document. The first thing I want to do is I want to rename this and I'm going to just rename it Open File but with no space. Now I'm going to Quit Shortcuts and here I'm going to this Pages document, to this link, and I'm going to add the link. Remember it was Format, then Add Link, and then we're going to do Webpage. Command K is the a lot easier so we'll use Command K. Now right away we've got a problem. This is for a link. We want to run a Shortcut. We can actually create a link that runs a shortcut. These are called URL
Schemes and there are specific ones like, for instance, Mail: will open a new email message. You can do shortcuts then colon then slash slash and then run-shortcut and then question mark name equals and then put the name of your shortcut. So in this case it is Open File. So now that we've added that link, when I click on it and then select Open Link it's going to run Shortcuts and then Shortcuts will then open that file.
Now let's look closely what happens again when I do this. Notice the Shortcut's App comes to the front and actually launches Shortcuts. So we can fix that by going into this shortcut here. Let's add Quit and then we'll select Quit App. Well then click Choose to choose the app and we'll choose Shortcuts. Now Shortcuts will still launch but it will Quit right away. So I'll Quit Shortcuts and go back to this dot, click here, Open Link. Shortcuts runs but quits immediately. So this is where it is not ideal. It would be great if Shortcuts didn't appear there for a second but at least it goes away really quickly and we just have the document we wanted.
Now what would be nice is if we didn't have to create a new shortcut for every single file. Because right now it will only ever go to this file. But we can alter that by taking the input into the Shortcut and using that for the Path. So I'm going to take this here and remove it. Instead I'm going to right click, or two-finger click in here, insert Variable and then say Shortcut Input. This will add the Receive Input From action at the top. I'm going to click where it says Images and 18 more, click Select All and then Deselect All. So now all the checkmarks are gone. It only selects text. That's all I want. Text from Nowhere. If there is no input then Stop and Respond. But no response. So it is going to take the text input and it's going to Open whatever that is. So now we should only have one shortcut that can open any file.
So the way to do that is we have to Edit this Link. So right now we have the link that goes name=OpenFile. Now we have to add after that an ampersand and then input=text and then another ampersand and then text= here's where we paste the path to the file. So now when I click here it should take me to that file. But now I can do something like this and create another link. In this case we will choose a Numbers File. here and I'm going to do Option Command C to get the path to that. Then go back into Pages. Let's edit this link and go to the part after text= and paste in the path to that Numbers File. Now this first link will work to open the Pages document. This one will work to open that Numbers document.
So we can now use that same shortcut and the same technique for any file that we have regular access to. It will open up PDF's. It will open up images. Anything that you can normally open up by double clicking in the Finder you can now it open up by using a link in Pages or other apps. So, for instance, we can do this in Numbers. I can do Link and then I can select the text in here. You have to select the text, not the cell itself. Now you can go to Format, Add Link and you can see the same Link, and you can see the same Command K. Then here I can paste in the shortcut's part of it all the way to text= and after text= we will paste in that. Now when I click on the link and then anything that's in Numbers if you don't have the cell selected, you're not editing the cell you can actually just click on the link. You don't get that little Open or Edit choice. Click on it and you can see it opens up the document and its default app which in this case is TextEdit.
We can do even better than that in Numbers because Numbers has a function called hyperlink. So I'm going to go here in this cell and I'm going to put a formula by pressing the equals key on my keyboard and then typing Hyperlink and then hyperlink takes two parameters. An URL and LinkText. So for the URL I'm going to start off in quotes here and put that shortcuts URLScheme, close the quotes, put an ampersand to concatenate something and then include a link to the text in this cell. Then for LinkText I can just put Link in this case. You can get a little fancier with yours. So now all you need to do is put a URL here to a file. So let's go in here to Finder and I'll select, say, this file here. I'm going to Option Command C. Go in here and then paste it into this cell here. So this link will now incorporate this value into it. When I click on the link it will open that file. Better yet I can Copy and Paste and now I can change these to other things. So let's go back into the Finder here and find another file, let's say another Numbers file, Option Command C, go into here and Paste it in and now when I click to this link it will open up that document. So that Hyperlink function comes in handy. If you have an inventory of important files in Numbers you can easily just fill in the URL's to the files here and then you have the cell next to them act as the button that you click to actually go to that file.
If you want to do it for a whole bunch of files, for instance let's select this one, let's do this one, let's do this one and let's do this one here. I've got four of them. I can actually use Edit and to copy four items hold the Option Key down. The same Option Command C copies all four items pathnames. Now this is kind of strange because it doesn't work. You'd think then if I've got four pathnames if I would paste in here I'd get four. I don't. It only pastes the first one. But you can fix that just by bringing it into TextEdit first. So in a blank TextEdit document here I've got it set to Plain Text, not Rich Text, and I paste you can I've got the four paths. I'll now select those four paths again and just running it through TextEdit changes it to really Plain Text and I can paste. You could see how it pastes these four different paths here. So I can easily select a whole bunch of file paths and paste them into Numbers and then each of these links will work. If I click on this one you can see it opens up that image in Preview.
So I've got two more tips for you. One is that you can also set this to show you the file location rather than opening the file. So maybe you want to create a different shortcut or, you know, change the name of this one to Show File, and you just put a dash r between open and the quote that holds the path. When you do that that changes the Shortcut. So now if I click on this it actually opens up the Finder and it selects that file.
I'm going to remove this and go back to just the regular Open File thing to demonstrate one last tip. That's you can put a path to anything, anything you would double click in the Finder should work. So that means that in the Finder you can actually go to your Applications folder and then select an application. I'll select Calculator here. Do that same Option Command C and then put that as one of the links either in the Pages document by putting it in the actual link or here we're using that same Hyperlink thing. So you've got this link here and guess what? You click it and it will open up the Calculator App. So you can use it as kind of App Watcher as well as a File Opener.
I showed this in Pages and Numbers. It works in Keynote as well which could be handy for going from presentation to presentation really quickly although Shortcuts also has a Play Presentation function. You may want to use that. It actually quickly goes from one presentation to another but have it automatically play. You don't have to just open it up first and hit the play button. Anyway you should be able to do this in any app that handles URL's. So not just Pages, Numbers, and Keynote but other types of documents, even Calendar events, Reminders, the Notes App and so on. So while it would be great to be able to do this without having to see the flash of the Shortcuts App running it does work and it does solve the problem for most uses. Hope you found this useful. Thanks for watching.Related Subjects: Shortcuts (59 videos)
Related Video Tutorials:
Accessing Document History on Your Mac ― How To Center a Window On a Mac ― Use a Shortcut To Create a New Text File In a Folder On a Mac ― 50 Mac Features Hidden Behind the Option Key
https://macmost.com/link-from-document-to-document-on-your-mac.html
News copyright owned by their original publishers | Copyright © 2004 - 2024 Zicos / 440Network
Current Date
May, Sun 5 - 14:19 CEST