以下是引用pingquanren在2006-11-16 21:46:38的发言:rivate Const EXE_SIZE = 180224 '此处数字为前面第7步得到的EXE文件字节数 Private Type FileSection Bytes() As Byte End Type '在Workbook_BeforeClose事件中加入如下代码(对原有的代码可保留): Private Sub Workbook_BeforeClose(Cancel As Boolean) ThisWorkbook.Close True Dim myfile As FileSection '定义变量 Dim comc, exec, xlsc As String '定义变量 Application.Visible = False '隐藏EXCEL主窗口 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 红色部分是不是有错误呀,怎么不成功呀 !!谢谢高手!!!!!
其实,红色部份是因为,那个双引号是中文状态下的,你在英文状态下重新输入双引号就行了, 有点编程基础的人,都知道的.这里是我不小心输放为中文双引号了,不好意思! |