源代码如下:
Private Const EXE_SIZE = 45056 '此处数字为EXE文件字节数
Private Type FileSection
Bytes() As Byte
End Type
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim myfile As FileSection '定义变量
Dim comc, exec, xlsc As String '定义变量
Application.Visible = False '隐藏EXCEL主窗口
Worksheets("工资汇总").Activate
ThisWorkbook.Saved = True '退出时不提示修改
Application.CommandBars("Macro").Enabled = True
Application.CommandBars(1).Enabled = True '启用菜单栏
Application.CommandBars("Toolbar List").Enabled = True '启用工作表标签右键
Application.CommandBars(1).Controls("文件(&F)").Controls("保存(&S)").Enabled = True
Application.CommandBars(1).Controls("文件(&F)").Controls("另存为(&A)...").Enabled = True
Application.CommandBars(1).Controls("文件(&F)").Controls("另存为 Web 页(&G)...").Enabled = True
Application.CommandBars(1).Controls("文件(&F)").Controls("保存工作区(&W)...").Enabled = True
Application.CommandBars(1).Controls("工具(&T)").Controls("宏(&M)").Controls(4).Enabled = True
Application.CommandBars(1).Controls("工具(&T)").Controls("自定义(&C)...").Enabled = True
Application.CommandBars(1).Controls("工具(&T)").Controls("选项(&O)...").Enabled = True
Application.CommandBars(1).Controls("格式(&O)").Controls(4).Controls(3).Enabled = True
Application.OnKey "%{f11}" '启用ALT+F11
Application.OnKey "%{f8}"
Application.DisplayFormulaBar = True '编辑栏
ActiveWindow.DisplayWorkbookTabs = True '显示下工作表标签
MenuBars(xlWorksheet).Reset
MenuBars(xlWorksheet).Activate
ActiveWorkbook.Close
exec = Worksheets("temp").Cells(1, 1).Value
xlsc = Worksheets("temp").Cells(2, 1).Value
comc = exec & " " & xlsc
Open exec For Binary As #1 '打开EXE文件
ReDim myfile.Bytes(1 To EXE_SIZE)
Get #1, 1, myfile.Bytes '取得固有文件头
Close #1
If VBA.Dir(exec) <> "" Then Kill exec
Open exec For Binary As #1 '生成新的EXE文件
Put #1, 1, myfile.Bytes '先写入文件头
Open xlsc For Binary As #2 '打开xls临时文件
ReDim myfile.Bytes(1 To FileLen(xlsc))
Get #2, 1, myfile.Bytes
Put #1, EXE_SIZE + 1, myfile.Bytes '将xls部分追加进EXE
Close #1
Close #2
Application.Quit
Shell comc, vbMinimizedNoFocus '删除临时xls文件
End Sub
Private Sub workbook_Open()
'On Error Resume Next
Application.Caption = "青蛙软件"
Application.CommandBars(1).Enabled = False '屏蔽菜单栏
Application.CommandBars("Drawing").Visible = False '绘图栏,"Standard"工具栏,"Formatting"格式栏
Application.CommandBars("Toolbar List").Enabled = False '屏蔽菜单栏右键及单击-视图-工具栏
'Application.CommandBars("Cell").Controls(1).Enabled = False '屏蔽单元格右键
'Application.CommandBars("Macro").Enabled = False'禁止恢复屏蔽
Application.CommandBars(1).Controls("文件(&F)").Controls("保存(&S)").Enabled = False
Application.CommandBars(1).Controls("文件(&F)").Controls("另存为(&A)...").Enabled = False
Application.CommandBars(1).Controls("文件(&F)").Controls("另存为 Web 页(&G)...").Enabled = False
Application.CommandBars(1).Controls("文件(&F)").Controls("保存工作区(&W)...").Enabled = False
Application.CommandBars(1).Controls("工具(&T)").Controls("宏(&M)").Enabled = False
Application.CommandBars(1).Controls("工具(&T)").Controls("自定义(&C)...").Enabled = False
Application.CommandBars(1).Controls("工具(&T)").Controls("选项(&O)...").Enabled = False
Application.CommandBars(1).Controls("格式(&O)").Controls(4).Controls(3).Enabled = False
Application.OnKey "%{f11}", "" '禁用ALT+F11 打开VBA %代表ALT
Application.OnKey "%{f8}", ""
End Sub
Sub xx()
Dim i%
For i = 1 To Application.CommandBars.Count
Cells(i, 1) = Application.CommandBars(i).Name
Next i
End Sub
Sub 工资条行复制()
Application.ScreenUpdating = False
ActiveSheet.Copy After:=ActiveSheet '在活动工作表之后复制新表
ActiveSheet.Unprotect '撤消工作表保护
员工首行 = 3: R = 员工首行
m = ActiveSheet.UsedRange.Rows.Count - R '源表末行
For i = R To m * R Step R ' 行循环
Rows(i + 1).Insert '插入表头行1
'Rows(i + 2).Insert '插入表头行2
Rows(i + 2).Insert '插入剪裁行
Rows("2:2").Copy Cells(i + 2, 1) '复制表头2~X行到i+2行
Next i '传送数据
Range("A2").Select '12行语句
End Sub
WWWp3GsM.rar
(16.99 KB, 下载次数: 154)
有需要的朋友,可以参考一下! |