Forum Discussion
Link excel cell to downloadable document
- Sep 21, 2023
Hi johngallagher,
Unfortunately, there is no direct way to create a link in Excel that will open a copy of the Word document immediately. When a user clicks on a hyperlink in Excel, they will always be taken to the original document, regardless of whether it is stored locally or online.
You can try to use a workaround with macro in Excel that will download the Word document and open it in a new window:- Open the Excel workbook where you want to add the macro.
- Press Alt + F11 to open the Visual Basic Editor (VBE).
- In the VBE, click Insert > Module.
- In the new module window, paste the following code:
Sub DownloadAndOpenWordDocument() 'Declare variables Dim wordApp As Object Dim wordDoc As Object Dim downloadPath As String 'Create a new instance of the Word application Set wordApp = CreateObject("Word.Application") 'Get the path to the Word document to download downloadPath = "https://example.com/my-word-document.docx" 'Download the Word document Set wordDoc = wordApp.Documents.Open(downloadPath) 'Open the Word document in a new window wordDoc.Visible = True End Sub
Click the Save button to save the macro.
- To assign the macro to a button, click Insert > Shapes and select the shape of the button you want to use.
- Right-click on the button and select Assign Macro.
- In the Assign Macro dialog box, select the DownloadAndOpenWordDocument macro and click Assign.
- To assign the macro to a keyboard shortcut, click Tools > Customize.
- In the Customize dialog box, click the Commands tab.
- In the Categories list, select Macros.
- In the Macros list, select the DownloadAndOpenWordDocument macro.
- Click the Assign Shortcut Key button.
- Press the keyboard shortcut you want to assign to the macro and click Assign.
- Click Close to close the Customize dialog box.
Now, when you click on the button or press the keyboard shortcut, the macro will run and download the Word document. The Word document will then open in a new window, where you can fill out the form and save it.
Please click Mark as Best Response & Like if my post helped you to solve your issue.
This will help others to find the correct solution easily. It also closes the item.If the post was useful in other ways, please consider giving it Like.
Kindest regards,
Leon Pavesic
Hi johngallagher,
Unfortunately, there is no direct way to create a link in Excel that will open a copy of the Word document immediately. When a user clicks on a hyperlink in Excel, they will always be taken to the original document, regardless of whether it is stored locally or online.
You can try to use a workaround with macro in Excel that will download the Word document and open it in a new window:
- Open the Excel workbook where you want to add the macro.
- Press Alt + F11 to open the Visual Basic Editor (VBE).
- In the VBE, click Insert > Module.
- In the new module window, paste the following code:
Sub DownloadAndOpenWordDocument()
'Declare variables
Dim wordApp As Object
Dim wordDoc As Object
Dim downloadPath As String
'Create a new instance of the Word application
Set wordApp = CreateObject("Word.Application")
'Get the path to the Word document to download
downloadPath = "https://example.com/my-word-document.docx"
'Download the Word document
Set wordDoc = wordApp.Documents.Open(downloadPath)
'Open the Word document in a new window
wordDoc.Visible = True
End Sub
Click the Save button to save the macro.
- To assign the macro to a button, click Insert > Shapes and select the shape of the button you want to use.
- Right-click on the button and select Assign Macro.
- In the Assign Macro dialog box, select the DownloadAndOpenWordDocument macro and click Assign.
- To assign the macro to a keyboard shortcut, click Tools > Customize.
- In the Customize dialog box, click the Commands tab.
- In the Categories list, select Macros.
- In the Macros list, select the DownloadAndOpenWordDocument macro.
- Click the Assign Shortcut Key button.
- Press the keyboard shortcut you want to assign to the macro and click Assign.
- Click Close to close the Customize dialog box.
Now, when you click on the button or press the keyboard shortcut, the macro will run and download the Word document. The Word document will then open in a new window, where you can fill out the form and save it.
Please click Mark as Best Response & Like if my post helped you to solve your issue.
This will help others to find the correct solution easily. It also closes the item.If the post was useful in other ways, please consider giving it Like.
Kindest regards,
Leon Pavesic
Thank you!
When I do this, do I then need to add the hyperlink after adding the macro for it to work? I tried adding the link to the word document and then also adding the macro, but it is still linking to the online page.
==edit==
I realized the link needs to be within the macro, my mistake!