Excel 文件到 exe(xls 到 exe)
Excel file to exe (xls to exe)
是否可以在不打开 excel 的情况下将带有宏的 xlsx sheet 转换为 exe 文件?我尝试了一些转换器,但都打开了 excel.
为此,您可以尝试从 excel 外部 运行 宏,如下所示 -
Set objExcel = CreateObject("Excel.Application")
objExcel.Application.Run "'full path to excel file'!module name.macro name"
objExcel.DisplayAlerts = False
objExcel.Application.Quit
Set objExcel = Nothing
要打开 read-only 工作簿,请尝试在 objExcel.Application.Run 行
之前添加以下行
集书 = objExcel.Workbooks.Open('full path to excel file',TRUE)
将代码粘贴到记事本中并另存为 VBS 文件。同时更改文件路径和宏名称。它以用户确认开始。
Option Explicit
Dim xlApp, xlBook
dim x
x=msgbox("Do You want to run the macro",4+64+0+4096,"Confirmation...")
if x= vbyes then
Set xlApp = CreateObject("Excel.Application")
'~~> Change Path here to your excel file
Set xlBook = xlApp.Workbooks.Open("C:\Users\Deb\Desktop\contactlist2.xlsm", 0, True)
'~~> Change macro name
xlApp.Run "check_data"
xlbook.save
xlBook.Close
xlApp.Quit
Set xlBook = Nothing
Set xlApp = Nothing
WScript.Echo "Finished."
WScript.Quit
end if
是否可以在不打开 excel 的情况下将带有宏的 xlsx sheet 转换为 exe 文件?我尝试了一些转换器,但都打开了 excel.
为此,您可以尝试从 excel 外部 运行 宏,如下所示 -
Set objExcel = CreateObject("Excel.Application")
objExcel.Application.Run "'full path to excel file'!module name.macro name"
objExcel.DisplayAlerts = False
objExcel.Application.Quit
Set objExcel = Nothing
要打开 read-only 工作簿,请尝试在 objExcel.Application.Run 行
之前添加以下行集书 = objExcel.Workbooks.Open('full path to excel file',TRUE)
将代码粘贴到记事本中并另存为 VBS 文件。同时更改文件路径和宏名称。它以用户确认开始。
Option Explicit
Dim xlApp, xlBook
dim x
x=msgbox("Do You want to run the macro",4+64+0+4096,"Confirmation...")
if x= vbyes then
Set xlApp = CreateObject("Excel.Application")
'~~> Change Path here to your excel file
Set xlBook = xlApp.Workbooks.Open("C:\Users\Deb\Desktop\contactlist2.xlsm", 0, True)
'~~> Change macro name
xlApp.Run "check_data"
xlbook.save
xlBook.Close
xlApp.Quit
Set xlBook = Nothing
Set xlApp = Nothing
WScript.Echo "Finished."
WScript.Quit
end if