Microsoft Developer Network > Página Inicial dos Fóruns > Visual C# General > Excel automation works on my computer but crashes on others
Fazer uma PerguntaFazer uma Pergunta
 

RespondidoExcel automation works on my computer but crashes on others

  • domingo, 8 de novembro de 2009 1:34ryanphillips112 Medalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuário
     
    I have written a program to automate a few things in Excel with Visual C# 2008 Express Edition. My program is targeted to .Net 2.0 as this is what the company computers all have installed and upgrading is not an option. On the development computer I have Office 2003 basic installed but the company computers all have 2003 pro. In searching if there were different PIA's for pro versus basic i didn't find anything. I did notice that security settings dictate that the user have admin or power user priveledges but all users at my company have power user priveledges. Everything works great on the development computer but once I try and run it on a company computer it won't work, it just instantly crashes. So I remarked out all the Excel specific code except the using statement and I left the reference to the Microsoft Office 11 object library and the program didn't crash anymore. As soon as I un-remark any Excel specific code (Microsoft.Office.Interop.Excel.Application xApp = new Microsoft.Office.Interop.Excel.ApplicationClass();), the program crashes on the company computers. Can anyone help me with this frustrating problem?

Respostas

  • quarta-feira, 11 de novembro de 2009 5:42ryanphillips112 Medalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuário
     Respondido
    I found the problem. I guess if you have Microsoft Office 2007 installed also and even though the reference you add is library version 11 it will still go for the latest version of Office / Excel. I uninstalled both versions of MS Office, reinstalled 2003, deleted all my references in the program and then re-added the reference to the MS Office 11 library. Everything works great now!
    • Marcado como Respostaryanphillips112 quarta-feira, 11 de novembro de 2009 5:42
    •  

Todas as Respostas

  • domingo, 8 de novembro de 2009 3:45Duppy Geezus Medalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuário
     Resposta Proposta
    install the same version of office on both the dev & production servers?
    • Sugerido como RespostaGnanadurai quarta-feira, 11 de novembro de 2009 5:45
    •  
  • quarta-feira, 11 de novembro de 2009 5:42ryanphillips112 Medalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuário
     Respondido
    I found the problem. I guess if you have Microsoft Office 2007 installed also and even though the reference you add is library version 11 it will still go for the latest version of Office / Excel. I uninstalled both versions of MS Office, reinstalled 2003, deleted all my references in the program and then re-added the reference to the MS Office 11 library. Everything works great now!
    • Marcado como Respostaryanphillips112 quarta-feira, 11 de novembro de 2009 5:42
    •