【问题标题】:Excel file to exe (xls to exe)Excel 文件转 exe(xls 转 exe)
【发布时间】:2017-02-14 00:37:18
【问题描述】:

是否可以在不打开 excel 的情况下将带有宏的 xlsx 工作表转换为 exe 文件?我尝试了一些转换器,但都打开了 excel。

【问题讨论】:

  • 你想通过将xls文件转换为exe来达到什么目的,但还是不想打开excel? @Fiinek?
  • 我想屏蔽菜单和所有编辑功能。

标签: excel exe vba


【解决方案1】:

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

【讨论】:

    【解决方案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)

    【讨论】:

    • 整张纸?
    • 请检查链接。那里给出了如何以只读模式打开工作簿。
    • 如果此答案对您有用,请将其标记为答案。
    猜你喜欢
    • 2013-06-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-11-05
    相关资源
    最近更新 更多