Close all Hyperlinked Files

Prasad K

Board Regular
Joined
Aug 4, 2021
Messages
189
Office Version
  1. 2016
  2. 2007
Platform
  1. Windows
Hi Excel Friends

How to close all opened hyperlinked files by vba code here i have applied this below vba it's not working

and one more if i close excel workbook then close all opened hyperlinked files automatically


VBA Code:
Sub CloseHyperLinks()
    Dim xHyperlink As Hyperlink
    Dim WorkRng As Range
    On Error Resume Next
    Set WorkRng = Range("A2:A5")
    For Each xHyperlink In WorkRng.Hyperlinks
        xHyperlink.Close
        xHyperlink.Quit
    Next
End Sub
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Are files that are opened using hyperlinks Excel files or other types?
 
Upvote 0
I presume these were opened using links in an Excel workbook?
 
Upvote 0
I presume these were opened using links in an Excel workbook?
Yes sir
hyperlinks files are opened by excel workbook in range A2 to A5 here what i want if i run vba macro then all opened hyperlinks files should be close at once & one more if i close my excel workbook then all opened files should be close automatically
 
Upvote 0

Forum statistics

Threads
1,214,978
Messages
6,122,549
Members
449,089
Latest member
davidcom

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top