Sorry, I ACK'D a bit:
Function GetInfo(Path As String, WBName As String, RetVal) As Boolean Dim wb As Workbook Dim bolClosed As Boolean '//attempt to set a reference // On Error Resume Next Set wb = Workbooks(WBName) On Error GoTo 0 '// If is Nothing, then not open // If wb Is Nothing Then '// Tack in trailing seperator // If Not Right(Path, 1) = "\" Then Path = Path & "\" '// attempt open // On Error Resume Next Set wb = Workbooks.Open(Path & WBName) On Error GoTo 0 '// if not Nothing, then opened. Else bailout // If Not wb Is Nothing Then GetInfo = True Else Exit Function End If '// If wb was Nothing originally, flag, so we can // '// close. // bolClosed = True Else GetInfo = True End If '// Do something here. I just retuned a val. // RetVal = wb.Sheets(1).Range("A1").Value '// If closed initially, re-close // If bolClosed Then wb.Close False End Function




Reply With Quote