VBA Before close - Check External links

Myproblem

Board Regular
Joined
May 24, 2010
Messages
198
i am trying to find or write VBA for excel in the case that macro is activated in the time before close.
i work on the same file as my collegues but sometimes they put links in that file, which driwe me crazy because we used to lost that sources.

i was wondering what macro would be to check workbook whatever there is or not any of the external links to other sources (other then that workbook).
I know that procedure for this kind of problem would be before_close, but i do not konow any furhter

any tips
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
i found two macros whic would satisfy my needs, but i do not know how to combine it
here is one before_close
Private Sub Workbook_BeforeClose(Cancel As Boolean)<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:eek:ffice:eek:ffice" /><o:p></o:p>
a = MsgBox("Do you know that you have external links", vbYesNo)<o:p></o:p>
If a = vbNo Then Cancel = True<o:p></o:p>
End Sub

and second, external links found
Sub external_links()

Dim rngExtLink As Range

Set rngExtLink = Cells.Find(What:="", After:=ActiveCell, LookIn:=xlFormulas, LookAt:=xlPart, _
SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, _
SearchFormat:=False)

If Not rngExtLink Is Nothing Then

MsgBox "External Link found!"

Else
MsgBox "No external links found!"
End If
End Sub

how to write just one to solve problem
 
Upvote 0
The Sub external_links() example you posted will not find external links.

The example at this link might work for you. It gives your user the option to list all external references or delete them.

http://www.exceltip.com/st/List,_ch...(links)_using_VBA_in_Microsoft_Excel/487.html

To run this before closing the workbook, add the code at the link above to standard code module
and add the code below to the ThisWorkBook module.

Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
    DeleteOrListLinks
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,064
Messages
6,122,942
Members
449,094
Latest member
teemeren

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