Общее·количество·просмотров·страницы

четверг, 25 февраля 2010 г.

Does object exist?

Check if a object exist exists


In this procedure we doesn't use Dir function
CODE
Sub FileExists()
Dim fso
Dim file As String
file = "C:\Test.xls" ' change to match the file w/Path
Set fso = CreateObject("Scripting.FileSystemObject")
If Not fso.FileExists(file) Then
MsgBox file & " was not located.", vbInformation, "File Not Found"
Else
MsgBox file & " has been located.", vbInformation, "File Found"
End If
End Sub

www.tek-tips.com

Check if file exist
Function Is_sheet_exist(Sheet_name As String, book As Workbook, Worksheet_type As Long) As Boolean
' Worksheet_type.
' Can be one of xlWorksheet, xlExcel4MacroSheet, or xlExcel4IntlMacroSheet.

Dim current_sheet As Worksheet
Is_sheet_exist = True
For Each current_sheet In book.Worksheets
If current_sheet.Name = Sheet_name And current_sheet.Type = Worksheet_type Then Exit Function
Next current_sheet

Is_sheet_exist = False
End Function
forum.ru-board.com/

Комментариев нет:

Отправить комментарий