Take it easy!


by achi on Dec.15, 2008, under VB.NETテクニック

Imports Excel = Microsoft.Office.Interop.Excel
    ‘Open: fExcelOpen(ExFileName) = True
    Private Function fExcelOpen(ByVal ExFileName As String) As Boolean
        Dim oExcel As Excel.Application
        Dim oBooks As Excel.Workbooks
        Dim oBook As Excel.Workbook
        Dim fsts As Boolean = “False”
        Dim oSheets As Excel.Sheets
        Dim oSheet As Excel.Worksheet
            oExcel = GetObject(, “Excel.Application”)
            oBooks = oExcel.Workbooks
            For Each oBook In oBooks
                If oBook.Name = ExFileName Then
                    fsts = True
                End If
        Catch ex As Exception
            If Not oSheet Is Nothing Then
                oSheet = Nothing
            End If
            If Not oSheets Is Nothing Then
                oSheets = Nothing
            End If
            If Not oBook Is Nothing Then
                oBook = Nothing
            End If
            If Not oBooks Is Nothing Then
                oBooks = Nothing
            End If
            If Not oExcel Is Nothing Then
                oExcel = Nothing
            End If
        End Try
        Return fsts
    End Function

2 comments for this entry:
  1. KattyBlackyard

    The best information i have found exactly here. Keep going Thank you

  2. Ada

    You made some good points on this subject.

Leave a Reply

*----* Note : *----*
Please write only in Japanese or English.
If you will post any other languages, we'll mark them as spam.

And also if a linked URI in your comments, I do not approve.

You must be logged in to post a comment.