From: hervinder on
Is it possible to test if a workbook has external links to another workbookl

what i am trying to do is display a message when a user closes a workbook
saying the workbook has external links.

How would i code this??
From: Dennis Tucker on
I believe there is a security setting that does this check when the workbook
opens(Excel 2007).



"hervinder" <hervinder(a)discussions.microsoft.com> wrote in message
news:08A95302-287D-4E91-A841-84F44CA309A4(a)microsoft.com...
> Is it possible to test if a workbook has external links to another
> workbookl
>
> what i am trying to do is display a message when a user closes a workbook
> saying the workbook has external links.
>
> How would i code this??

From: Dave Peterson on
I'm not sure what you want to do, but maybe...

Option Explicit
Private Sub Workbook_BeforeClose(Cancel As Boolean)

Dim myLinks As Variant
Dim iCtr As Long

myLinks = Me.LinkSources(xlExcelLinks)
If IsEmpty(myLinks) Then
'do nothing
Else
Msgbox "it has links!"
'maybe loop thrugh them (as an example
For iCtr = LBound(myLinks) To UBound(myLinks)
MsgBox myLinks(iCtr)
Next iCtr
End If

End Sub

This code goes into the ThisWorkbook module of the workbook's project.

hervinder wrote:
>
> Is it possible to test if a workbook has external links to another workbookl
>
> what i am trying to do is display a message when a user closes a workbook
> saying the workbook has external links.
>
> How would i code this??

--

Dave Peterson
From: hervinder on
unfortunately i'm still using excel 2003

all i want is something along the lines of

if activeworkbook.externallinks = true then msgbox "this book contains
external links"

if only it was as easy as that


"Dennis Tucker" wrote:

> I believe there is a security setting that does this check when the workbook
> opens(Excel 2007).
>
>
>
> "hervinder" <hervinder(a)discussions.microsoft.com> wrote in message
> news:08A95302-287D-4E91-A841-84F44CA309A4(a)microsoft.com...
> > Is it possible to test if a workbook has external links to another
> > workbookl
> >
> > what i am trying to do is display a message when a user closes a workbook
> > saying the workbook has external links.
> >
> > How would i code this??
>
> .
>
From: hervinder on
thanks dave

works a treat

"Dave Peterson" wrote:

> I'm not sure what you want to do, but maybe...
>
> Option Explicit
> Private Sub Workbook_BeforeClose(Cancel As Boolean)
>
> Dim myLinks As Variant
> Dim iCtr As Long
>
> myLinks = Me.LinkSources(xlExcelLinks)
> If IsEmpty(myLinks) Then
> 'do nothing
> Else
> Msgbox "it has links!"
> 'maybe loop thrugh them (as an example
> For iCtr = LBound(myLinks) To UBound(myLinks)
> MsgBox myLinks(iCtr)
> Next iCtr
> End If
>
> End Sub
>
> This code goes into the ThisWorkbook module of the workbook's project.
>
> hervinder wrote:
> >
> > Is it possible to test if a workbook has external links to another workbookl
> >
> > what i am trying to do is display a message when a user closes a workbook
> > saying the workbook has external links.
> >
> > How would i code this??
>
> --
>
> Dave Peterson
> .
>