Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 140
Default check for links

I will be grateful for a pece of code to check if a workbook opened by the
running macro has any links
--
with kind regards

Spike
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 100
Default check for links

Hi Spike,

Try using the following function:

Function HasLink(WbName As String) As Boolean
HasLink = Not IsEmpty(Workbooks(WbName).LinkSources)
End Function

Sub TestHasLink()
On Error Resume Next
If HasLink("Book1.xlsm") Then
If Err = 9 Then Exit Sub 'If this workbook name is not valid

MsgBox "This Workbook has a link"
Else
MsgBox "No links"
End If
End Sub

Make sure that the parameter you pass as WbName is the name of an open
Workbook, and include the extension i.e .xls or xlsm...
--
A. Ch. Eirinberg


"Spike" wrote:

I will be grateful for a pece of code to check if a workbook opened by the
running macro has any links
--
with kind regards

Spike

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 100
Default check for links

Just to clerify, the funcftion will only tell you if that workbook is linked
to another workbook and not if another workbook is linked to it.
--
A. Ch. Eirinberg


"Howard31" wrote:

Hi Spike,

Try using the following function:

Function HasLink(WbName As String) As Boolean
HasLink = Not IsEmpty(Workbooks(WbName).LinkSources)
End Function

Sub TestHasLink()
On Error Resume Next
If HasLink("Book1.xlsm") Then
If Err = 9 Then Exit Sub 'If this workbook name is not valid

MsgBox "This Workbook has a link"
Else
MsgBox "No links"
End If
End Sub

Make sure that the parameter you pass as WbName is the name of an open
Workbook, and include the extension i.e .xls or xlsm...
--
A. Ch. Eirinberg


"Spike" wrote:

I will be grateful for a pece of code to check if a workbook opened by the
running macro has any links
--
with kind regards

Spike

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 140
Default check for links

Thank you very much for that works a treat
--
with kind regards

Spike


"Howard31" wrote:

Just to clerify, the funcftion will only tell you if that workbook is linked
to another workbook and not if another workbook is linked to it.
--
A. Ch. Eirinberg


"Howard31" wrote:

Hi Spike,

Try using the following function:

Function HasLink(WbName As String) As Boolean
HasLink = Not IsEmpty(Workbooks(WbName).LinkSources)
End Function

Sub TestHasLink()
On Error Resume Next
If HasLink("Book1.xlsm") Then
If Err = 9 Then Exit Sub 'If this workbook name is not valid

MsgBox "This Workbook has a link"
Else
MsgBox "No links"
End If
End Sub

Make sure that the parameter you pass as WbName is the name of an open
Workbook, and include the extension i.e .xls or xlsm...
--
A. Ch. Eirinberg


"Spike" wrote:

I will be grateful for a pece of code to check if a workbook opened by the
running macro has any links
--
with kind regards

Spike

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Print specific cells to another worksheet if check box cell links Clinton W[_2_] Excel Discussion (Misc queries) 0 August 31st 09 12:19 AM
check for links Spike Excel Programming 2 June 1st 09 08:45 AM
Check for Addin before Update Links John Michl Excel Programming 2 June 9th 07 05:10 AM
Find & Replace Cell Links for Check Boxes Teasee Excel Discussion (Misc queries) 2 May 30th 07 03:30 PM
Check box links Sparky13 Excel Discussion (Misc queries) 0 December 14th 06 01:43 PM


All times are GMT +1. The time now is 08:59 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"