How to change the Excel document icon [closed]

1

I want to change the excel document icon, to have another face and look like an executable, or something, can you help me?

    
asked by anonymous 20.06.2017 / 09:35

1 answer

1

To change the icon, simply create a shortcut (eg desktop), click on the properties of the file (shortcut) and click on the Alterar Ícone button and choose the desired icon.

Another option would be to create an executable file to open the file already with macros enabled :

  • Create a file with the following code, changing the line where it indicates where in the local folder the file is, and save it to the desired location (eg C: \ tmp) with .cs extension :

    using System;
    using System.Collections.Generic;
    using System.Reflection;
    using System.Threading;
    using System.Windows.Forms;
    
        static class Program
    {
        // variáveis de instãncia
        static object oExcel = null;
        static object oBooks = null;
        static object oBook = null;
        static object oMissing = System.Reflection.Missing.Value;
        static System.Globalization.CultureInfo ci = Thread.CurrentThread.CurrentCulture;
    
        [STAThread]
        static void Main()
        {
            string CaminhoDoArquivo = @"C:\Caminho\Para\Seu\Arquivo\Excel\ExcelComMacros.xlsm";
    
            if (ExcelEstaInstalado())
            {
                try
                {
                    if (System.IO.File.Exists(CaminhoDoArquivo))
                    {
                        AbrirArquivo(CaminhoDoArquivo);
                    }
                    else
                    {
                        MessageBox.Show(string.Format("O arquivo {0} não foi encontrado", CaminhoDoArquivo));
                    }
                }
                catch (System.IO.IOException)
                {
                    MessageBox.Show("Erro de acesso ao arquivo. Verifique o arquivo de configuração ou as permissões de pasta");
                }
            }
            else
            {
                MessageBox.Show("Não foi possível encontrar a instalação do Microsoft Excel no seu computador");
            }
    
            Application.Exit();
        }
    
        private static void AbrirArquivo(string caminhoDoArquivo)
        {
            object oFileName = caminhoDoArquivo;
            oExcel = Activator.CreateInstance(Type.GetTypeFromProgID("Excel.Application"));
            oExcel.GetType().InvokeMember("AutomationSecurity", BindingFlags.SetProperty, null, oExcel, new object[] { 1 }, ci);
            oExcel.GetType().InvokeMember("Visible", BindingFlags.SetProperty, null, oExcel, new object[] { true }, ci);
            oBooks = oExcel.GetType().InvokeMember("Workbooks", BindingFlags.GetProperty, null, oExcel, null, ci);
            oBook = oBooks.GetType().InvokeMember("Open", BindingFlags.InvokeMethod, null, oBooks, new object[] { oFileName, oMissing, false }, ci);
        }
    
        public static bool ExcelEstaInstalado()
        {
            Type officeType = Type.GetTypeFromProgID("Excel.Application");
    
            if (officeType == null)
            {
                return false;
            }
            else
            {
                return true;
            }
        }
    }
    
  • This is a file in C language.

  • Open a prompt (Windows key + R and type CMD)

  • Access the c:\Windows\Microsoft.NET\Framework\v2.0.50727 folder:

    cd c:\Windows\Microsoft.NET\Framework\v2.0.50727
    
  • Enter the following code:

    csc.exe /target:winexe /out:"C:\Caminho\Do\Executavel\ArquivoExecutavel.exe" "C:\Caminho\Para\Arquivo\C\ScriptEmLinguagemC.cs"
    
  • Remembering to change the paths to where your files are.

    Ready! You will have an executable to run your spreadsheet.

        
    20.06.2017 / 14:35