Prev: Opened applications
Next: Macro Please
From: KB on 18 Mar 2010 12:56 Is there a way in VBA to detect if the source file for a specific link is open?
From: Gary Brown on 18 Mar 2010 15:28 '/================================================/ ' Function Purpose: Returns TRUE if workbook is open ' Returns FALSE if workbook is NOT open ' syntax of strWkbkName is FULL Name ' example: "D:\Temp\Hello.xls" ' strWkbkName must be a string ' '/================================================/ Public Function WorkbookIsOpen(strWkbkName As String) As Boolean Dim blnResult As Boolean Dim iWorkbooks As Double, x As Double On Error GoTo err_Function blnResult = False 'count number of open workbooks iWorkbooks = Application.Workbooks.Count If iWorkbooks < 1 Then GoTo exit_Function End If For x = 1 To iWorkbooks If Application.Workbooks(x).FullName = strWkbkName Then blnResult = True End If Next x WorkbookIsOpen = blnResult exit_Function: On Error Resume Next Exit Function err_Function: Debug.Print "Error: " & Err.Number & " - (" & _ Err.Description & _ ") - Function: WorkbookIsOpen - " & _ "Module: Mod_Functions_WorkbookIsOpen - " & Now() GoTo exit_Function End Function '/================================================/ -- Hope this helps. If it does, please click the Yes button. Thanks in advance for your feedback. Gary Brown "KB" wrote: > Is there a way in VBA to detect if the source file for a specific link is open?
|
Pages: 1 Prev: Opened applications Next: Macro Please |