1

I have build a tool using VBA (.xlsm) and would like to convert it to an .exe file. I would like that excel icon is not showing once converted in to an .exe file (acting as a custom app). I know you can create a shortcut and change the icon, but would like completely to remove the excel icon, or at least still have the excel file somewhere in the folder but be accessible via .exe icon.

Any idea what is the best way to do it?

Thanks a lot!

L42
  • 19,427
  • 11
  • 44
  • 68
user3536226
  • 41
  • 1
  • 1
  • 7
  • 3
    If your xlsm is fully developed in Excel (VBA), I think you cannot do that because xlsm needs Excel by itself, that means the icon will be the same always, unless you change ALL the icons related to Excel. Maybe you should try to develope it in Visual Studio and then make your own Exe file. I'm not posting this as an answer because I'm not 100% sure, but that's what i've heard. More info: https://social.msdn.microsoft.com/Forums/en-US/c1315062-45dd-4a01-8014-c138f086a76b/making-excelxlsm-into-exe?forum=exceldev – Foxfire And Burns And Burns Jan 14 '18 at 16:50
  • if you google "excel to exe" you can find products that can make .exe from Excel file, but none of them is free – Slai Jan 18 '18 at 03:08

2 Answers2

2

If you are limited to developing in Excel, you can try using VB script to launch Excel.
How do you do that?

  1. Using Notepad, create a .vbs file. How do you create one?
    Just save the file and then select All Files(*) in the File Save As Dialog Box.
    Create a useful name and use .vbs extension.
    And thats it, you now have a Vb Script executable file.

    enter image description here

  2. Then write the code to open and launch your Excel.
    You can take a look at what brettdj has to say here.
    Take note of David's comment though. If you need to open the workbook in Readonly (no need to save workbook, it is a template) or ReadWrite (needs saving the workbook after running macro) mode. Simplest code would look something like what brettdj wrote. Let's just pay attention to opening the workbook as ReadOnly.

    xlFilePath = "C:\User\Username\myexelfile.xlsm"
    Set xlWb = xlApp.Workbooks.Open(xlFilePath, 0, True) '/* opens as ReadOnly */
    

    Change True to False to make it ReadWrite. Save and your exe file is done.

  3. Since you want an executable file, I assume you have forms in Excel.
    If my assumption is correct, you can then use Events to close and terminate Excel.
    Something like below which closes the workbook after closing the Userform.

    Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
        ThisWorkbook.Close False '/* do not save changes */    
    End Sub
    
  4. You will have to use another Event on the workbook itself to close the Excel Application.
    Which should look something like below:

    Private Sub Workbook_BeforeClose(Cancel As Boolean)
        Application.Quit '/* quits Excel before actually closing the workbook */
    End Sub
    
L42
  • 19,427
  • 11
  • 44
  • 68
0

You can easily create an .exe file using Visual Studio. I have never, ever, heard of anyone using Excel to create an .exe file.

https://www.youtube.com/watch?v=CEpiZqSlPGg

There is a huge upside to using Visual Studio! Anything using the managed environment (which includes anything written in C# and VB.NET) requires the .NET framework. You can simply redistribute your .EXE in that scenario, but they'll need to install the appropriate framework if they don't already have it.

ASH
  • 20,759
  • 19
  • 87
  • 200