I have a VB program which involves opening Excel files. To do this I had to add the Microsoft Excel Object Library to my projects' references. There was no problem here until a friend tried to run my project on his computer. The application would start, however once a command to open an excel file was selected, the following error was displayed:
Unhandeled exception has occured in your application. Could not load file or assembley 'Microsoft.Office.Interop.Excel, version=11.0.0.0 Culture = neutral. The system could not find the specified file.
Does anyone know how to correct this error which only occurs on my friends computer after the project has been published. (it works fine on my PC.)
Thanks in anticipation, Andy

Microsoft.Office.Interop Error
KeWin
Yes, they are required & should not be included in the setup project.
Look at http://msdn.microsoft.com/library/default.asp url=/library/en-us/stagsdk/html/stconPIAs_HV01083002.asp for more info.
[edit]
I just found out that they are available as a seperate download (Office 2003 Update: Redistributable Primary Interop Assemblies): http://www.microsoft.com/downloads/details.aspx FamilyID=3c9a983a-ac14-4125-8ba0-d36d67e0f4ad&DisplayLang=en
[/edit]
Sven
ruben_ruvalcaba_camba
Ok, thanks for the new code. I started a new project in order to remove all the references in the old project but imported the forms and excel files into my new project.
The excel files are set to 'embedded' in the application so that the application is a single .exe file.
I have used the new code you gave me above, however the following error message appeared at runtime on my friends pc.:
"See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.
************** Exception Text **************
System.ComponentModel.Win32Exception: The system cannot find the file specified
at System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startInfo)
at System.Diagnostics.Process.Start()
at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)
at SWFC_Stats.frmStart.cbxPastSeason_SelectedIndexChanged(Object sender, EventArgs e)
at System.Windows.Forms.ComboBox.OnSelectedIndexChanged(EventArgs e)
at System.Windows.Forms.ComboBox.WmReflectCommand(Message& m)
at System.Windows.Forms.ComboBox.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
************** Loaded Assemblies **************
mscorlib
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
----------------------------------------
SWFC Stats
Assembly Version: 1.0.0.0
Win32 Version: 5.0.1.0
CodeBase: file:///C:/Documents%20and%20Settings/xxx/My%20Documents/My%20Received%20Files/SWFC%20Stats.exe
----------------------------------------
Microsoft.VisualBasic
Assembly Version: 8.0.0.0
Win32 Version: 8.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/Microsoft.VisualBasic/8.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualBasic.dll
----------------------------------------
System
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Windows.Forms
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System.Drawing
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System.Runtime.Remoting
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Runtime.Remoting/2.0.0.0__b77a5c561934e089/System.Runtime.Remoting.dll
----------------------------------------
************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.
For example:
<configuration>
<system.windows.forms jitDebugging="true" />
</configuration>
When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box."
Does this give anyone a clue to how to solve my problem
Thanks, Andy
tculler
If all you want to do, is open an excel file (i.e. Launch excel & open the file), you can remove the reference to the excel library and use the following code
This will open the file.
Yhack
You have to have the Microsoft Office PIA's installed. They are a part of the Office setup.
Modify your office setup through the 'add & remove programs' control panel applet
Choose add or remove features
Select the 'Choose advance customizations of applications' checkbox
Install the option '.NET programmabitlity support' for each office application.
Sven
Artur I.
Dragging the excel file from the solution explorer into the code provides the full direcotry length, however this will not work on other systems because the directory will differ on different machines.
I hope you understand my issue, all I'm trying to achieve is to open an excel file which is embedded into the .exe file of my application.
Thanks, Andy.
Martin Dietz
I might suggest that you post something in here as this is dealing specifically with Office Interop rather than the VB Language
· Working with the Office Primary Interop Assemblies (PIA): office.developer.automation newsgroup
http://msdn.microsoft.com/newsgroups/default.aspx dg=microsoft.public.officedev&lang=en&cr=US
Julien Gourdet SOPRA
Well, thanks for your help.
It does seem strange there isn't an easier way of doing this, all I want is a simple application that loads an excel file on click!
Steini
Does a file called c:\test.xls actually exist on your system
Also you may want to include some error handling - such as a Try ... Catch construct.
As this appears to product the same error message
Try
Dim pi As New System.Diagnostics.ProcessStartInfo
pi.FileName = "c:\test2222.xls"
System.Diagnostics.Process.Start(pi)
Catch ex As Exception
MsgBox(ex.ToString )
End Try
If I change the filename to one that exists then it will start up excel with this file loaded.
Whatfly
Ok, i have done that thanks, although the Excel one was already selected as 'run from my computer'.
Does the programmability support have to be installed on every system that tries to run my program