|
BobPan版主大贴:http://club.excelhome.net/viewthread.php?tid=283306
已被PS过两次见:
http://club.excelhome.net/viewthread.php?tid=289832
http://club.excelhome.net/viewthread.php?tid=284791
俺也来改进一下,呵呵
假设你想启动D:\newtest.xls文件,请按如下操作
打开VB6.0,建立一个EXE工程,双击默认窗体写下如下代码
Option Explicit
Private Sub Form_Load()
Open "C:\myVBScmd.vbs" For Output As #1
Print #1, "Set objXL = WScript.CreateObject(""Excel.Application"")"
Print #1, "objXL.Workbooks.Open ""D:\newtest.xls"""
Print #1, "objXL.Visible = True"
Print #1, "Set objXL = Nothing"
Close #1
Open "C:\mycmd.bat" For Output As #1
Print #1, "start C:\myVBScmd.vbs"
Print #1, "ping 127.0.0.1 -n 6 >nul"
Print #1, "del C:\myVBScmd.vbs"
Print #1, "del %0"
Close #1
Shell "C:\mycmd.bat", 0
Unload Me
End Sub
然后文件菜单下生成EXE文件,OK制作完成,优点是将代码封装进EXE文件,且不留中间文件,再次感谢BobPan版主
附上附件,附件下载后请将newtest.xls剪切至d盘根目录下,请测试
附上老版主的原话:
注:建议还是给用户应有的权利,让用户来选择是否启用宏
请不要用此方法制作病毒 |
|