Forum Discussion
Excel hyperlink default software to open FileName .pdf
To ensure that Excel uses the default software set in your Windows settings to open PDF files, you may need to check and adjust a few settings. Here are some steps you can take to resolve this issue:
Step 1: Verify Default App Settings in Windows
1. Open Default Apps Settings:
- Press Windows + I to open the Settings app.
- Go to Apps > Default apps.
2. Set Default PDF Viewer:
- Scroll down and click on Choose default apps by file type.
- Find .pdf in the list and make sure your preferred PDF viewer (e.g., Microsoft Edge, etc.) is set as the default app for this file type.
Step 2: Check File Association for Hyperlinks in Excel
Excel should respect the default file associations set in Windows. However, if it does not, you can try the following workaround:
Step 3: Repair Office Installation
Sometimes, the issue might be due to a corruption in the Office installation. Repairing Office can fix this.
1. Open Control Panel:
- Press Windows + R, type control, and press Enter.
2. Go to Programs and Features:
- Click on Programs > Programs and Features.
3. Repair Microsoft Office:
- Find Microsoft Office in the list, select it, and click on Change.
- Choose Repair and follow the on-screen instructions.
Step 4: Create a Custom VBA Function to Open PDFs
If the above methods do not work, you can create a custom VBA function in Excel to open PDFs using the default application. Here’s how you can do this:
1. Open the VBA Editor:
- Press Alt + F11 to open the Visual Basic for Applications editor.
2. Insert a New Module:
- In the VBA editor, go to Insert > Module.
3. Paste the Following Code:
Vba Code is untested backup your file.
Declare Function ShellExecute Lib "shell32.dll" _
Alias "ShellExecuteA" ( _
ByVal hwnd As Long, _
ByVal lpOperation As String, _
ByVal lpFile As String, _
ByVal lpParameters As String, _
ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long
Sub OpenPDF(filePath As String)
ShellExecute 0, "open", filePath, "", "", 1
End Sub
4. Use the Macro to Open PDFs:
- You can then use this macro to open PDFs from a specific cell. For example:
Vba Code is untested backup your file.
Sub OpenPDFfromCell()
Dim filePath As String
filePath = ThisWorkbook.Sheets("Sheet1").Range("A1").Value ' Adjust the range as needed
OpenPDF filePath
End Sub
Step 5: Assign Macro to a Button (Optional)
1. Insert a Button:
- Go to the Developer tab, click on Insert, and choose Button (Form Control).
2. Assign Macro:
- Draw the button on your sheet, and assign the OpenPDFfromCell macro to it.
By following these steps, you should be able to ensure that PDFs open with your preferred default software when clicking hyperlinks in Excel. The VBA workaround provides a custom solution that overrides Excel’s default behavior. The text, steps and code were created with the help of AI.
My answers are voluntary and without guarantee!
Hope this will help you.
Was the answer useful? Mark as best response and Like it!
This will help all forum participants.