Excel文件到exe(xls到exe)

时间:2017-02-13 11:22:00

标签: excel excel-vba exe vba

是否可以将xlsx sheet与宏转换为exe文件而无需打开excel?我尝试了一些转换器,但都打开了excel。

2 个答案:

答案 0 :(得分:2)

为此,您可以尝试从外部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

enter link description here

要打开只读工作簿,请尝试在objExcel.Application.Run行之前添加以下行

设置book = objExcel.Workbooks.Open(' excel文件的完整路径' ,, TRUE)

答案 1 :(得分:2)

将代码粘贴到记事本中并另存为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