Dim xlApp As Excel.Application '定义EXCEL类
Dim xlBook As Excel.Workbook '定义工件簿类
Dim xlsheet As Excel.Worksheet '定义工作表类
Private Sub Command1_Click() '更新工时数据
Dim lcmm As String
If Dir("" & App.Path & "\excel.bz") = "" Then '判断EXCEL是否打开
Set fs = CreateObject("Scripting.FileSystemObject")
fs.CopyFolder "\\192.168.X.X\路径", "E:\路径", True
'源文件夹 目标文件夹
MsgBox "更新成功"
Command2.Enabled = False
Command3.Enabled = False
Command4.Enabled = False
Command5.Enabled = False
Command6.Enabled = False
Command7.Enabled = False
Else
End
End If
Do
lcmm = InputBox("请输入查询密码", "查询密码", "")
Loop Until lcmm = "0123" Or lcmm = "1231" Or lcmm = "1232" Or lcmm = "1233" Or lcmm = "1234" Or lcmm = "1235" Or lcmm = ""
Select Case lcmm
Case "0123"
Command2.Enabled = True
Case "1231"
Command3.Enabled = True
Case "1232"
Command4.Enabled = True
Case "1233"
Command5.Enabled = True
Case "1234"
Command6.Enabled = True
Case "1235"
Command7.Enabled = True
End Select
End Sub
Private Sub Command2_Click() '运行工时汇总系统
If Dir("D:\temp\excel.bz") = "" Then '判断EXCEL是否打开
Set xlApp = CreateObject("Excel.Application") '创建EXCEL应用类
xlApp.Visible = True '设置EXCEL可见
Set xlBook = xlApp.Workbooks.Open("E:\路径\文件名.xlsm") '打开EXCEL工作簿
Set xlsheet = xlBook.Worksheets(1) '打开EXCEL工作表
'xlsheet.Activate '激活工作表
'xlsheet.Cells(1, 1) = "abc" '给单元格1行驶列赋值
xlBook.RunAutoMacros (xlAutoOpen) '运行EXCEL中的启动宏
Else
MsgBox ("EXCEL已打开")
End If
End
End Sub
Private Sub Command3_Click()
If Dir("D:\temp\excel.bz") = "" Then '判断EXCEL是否打开
Set xlApp = CreateObject("Excel.Application") '创建EXCEL应用类
xlApp.Visible = True '设置EXCEL可见
Set xlBook = xlApp.Workbooks.Open("E:\路径\文件名.xlsm") '打开EXCEL工作簿
Set xlsheet = xlBook.Worksheets(1) '打开EXCEL工作表
'xlsheet.Activate '激活工作表
'xlsheet.Cells(1, 1) = "abc" '给单元格1行驶列赋值
xlBook.RunAutoMacros (xlAutoOpen) '运行EXCEL中的启动宏
Else
MsgBox ("EXCEL已打开")
End If
End
End Sub
Private Sub Command4_Click()
If Dir("D:\temp\excel.bz") = "" Then '判断EXCEL是否打开
Set xlApp = CreateObject("Excel.Application") '创建EXCEL应用类
xlApp.Visible = True '设置EXCEL可见
Set xlBook = xlApp.Workbooks.Open("E:\路径\文件名.xlsm") '打开EXCEL工作簿
Set xlsheet = xlBook.Worksheets(1) '打开EXCEL工作表
'xlsheet.Activate '激活工作表
'xlsheet.Cells(1, 1) = "abc" '给单元格1行驶列赋值
xlBook.RunAutoMacros (xlAutoOpen) '运行EXCEL中的启动宏
Else
MsgBox ("EXCEL已打开")
End If
End
End Sub
Private Sub Command5_Click()
If Dir("D:\temp\excel.bz") = "" Then '判断EXCEL是否打开
Set xlApp = CreateObject("Excel.Application") '创建EXCEL应用类
xlApp.Visible = True '设置EXCEL可见
Set xlBook = xlApp.Workbooks.Open("E:\路径\文件名.xlsm") '打开EXCEL工作簿
Set xlsheet = xlBook.Worksheets(1) '打开EXCEL工作表
'xlsheet.Activate '激活工作表
'xlsheet.Cells(1, 1) = "abc" '给单元格1行驶列赋值
xlBook.RunAutoMacros (xlAutoOpen) '运行EXCEL中的启动宏
Else
MsgBox ("EXCEL已打开")
End If
End
End Sub
Private Sub Command6_Click()
If Dir("D:\temp\excel.bz") = "" Then '判断EXCEL是否打开
Set xlApp = CreateObject("Excel.Application") '创建EXCEL应用类
xlApp.Visible = True '设置EXCEL可见
Set xlBook = xlApp.Workbooks.Open("E:\路径\文件名.xlsm") '打开EXCEL工作簿
Set xlsheet = xlBook.Worksheets(1) '打开EXCEL工作表
'xlsheet.Activate '激活工作表
'xlsheet.Cells(1, 1) = "abc" '给单元格1行驶列赋值
xlBook.RunAutoMacros (xlAutoOpen) '运行EXCEL中的启动宏
Else
MsgBox ("EXCEL已打开")
End If
End
End Sub
Private Sub Command7_Click()
If Dir("D:\temp\excel.bz") = "" Then '判断EXCEL是否打开
Set xlApp = CreateObject("Excel.Application") '创建EXCEL应用类
xlApp.Visible = True '设置EXCEL可见
Set xlBook = xlApp.Workbooks.Open("E:\路径\文件名.xlsm") '打开EXCEL工作簿
Set xlsheet = xlBook.Worksheets(1) '打开EXCEL工作表
'xlsheet.Activate '激活工作表
'xlsheet.Cells(1, 1) = "abc" '给单元格1行驶列赋值
xlBook.RunAutoMacros (xlAutoOpen) '运行EXCEL中的启动宏
Else
MsgBox ("EXCEL已打开")
End If
End
End Sub
Private Sub Form_Load()
Label1.FontSize = 20
Label1.FontBold = True
Label1.FontItalic = True
End Sub
Private Sub Image1_Click()
MsgBox "本软件只适用XXX公司内部使用,最后更新时间2019年9月10日。"
End Sub