'檢測(cè)工作表
Function CheckSheet(ByVal strSheet As String, ByVal strWorkBook As String, xlCheckApp As Excel.Application) As Boolean
Dim L As Integer
Dim CheckWorkBook As Excel.Workbook
If CheckFile(strWorkBook) And strSheet <> "" And Not IsNull(strSheet) Then
For L = 1 To xlCheckApp.Workbooks.Count
If GetPath(xlCheckApp.Workbooks(L).Path) & xlCheckApp.Workbooks(L).Name = strWorkBook Then
Set CheckWorkBook = xlCheckApp.Workbooks(L)
Exit For
End If
Next L
Set CheckWorkBook = xlCheckApp.Workbooks.Open(strWorkBook)
For L = 1 To CheckWorkBook.Worksheets.Count
If CheckWorkBook.Worksheets(L).Name = Trim(strSheet) Then
CheckSheet = True
Exit For
End If
Next L
Else
MsgBox "工作表不存在,可能是由文件名或工作表名引起的!"
CheckSheet = False
End If
End Function
'建立工作表
'CreateMethod:1追加
'CreateMethod:2覆蓋
Function CreateSheet(ByVal strSheetName As String, ByVal strWorkBook As String, ByVal CreateMethod As Integer, xlCreateApp As Excel.Application) As Boolean
Dim xlCreateSheet As Excel.Worksheet
If CheckFile(strWorkBook) Then
xlCreateApp.Workbooks.Open (strWorkBook)
If CreateMethod = 1 Then
相關(guān)推薦:2011年上半年計(jì)算機(jī)等級(jí)考試報(bào)名時(shí)間匯總
2011計(jì)算機(jī)等級(jí)考試二級(jí)VB考點(diǎn)及習(xí)題匯總
北京 | 天津 | 上海 | 江蘇 | 山東 |
安徽 | 浙江 | 江西 | 福建 | 深圳 |
廣東 | 河北 | 湖南 | 廣西 | 河南 |
海南 | 湖北 | 四川 | 重慶 | 云南 |
貴州 | 西藏 | 新疆 | 陜西 | 山西 |
寧夏 | 甘肅 | 青海 | 遼寧 | 吉林 |
黑龍江 | 內(nèi)蒙古 |