I have an application with a VB6 user interface which calls a VB.NET (VS2010) DLL to generate report files in spreadsheet (.xlsx) and word processor (.docx) formats. I use DevExpress to generate the report files then have a generic method to call system.diagnostics.process
.start on the file to open the report file with what ever application the user has associated with that file type.
Public Shared Function OpenFileWithProcess(ByVal lsFileNameWithPath As String, Optional ByVal lPrintOption As PrintOutputOption = PrintOutputOption.Preview)
Select Case lPrintOption
Dim P As System.Diagnostics.Process
P = Process.Start(lsFileNameWithPath)
If Not P Is Nothing Then
Dim handle As IntPtr = P.Handle
Dim Proc As New Process
Proc.StartInfo.FileName = lsFileNameWithPath
Proc.StartInfo.UseShellExecute = True
Proc.StartInfo.Verb = "Print"
Catch ex As Exception
If oSQL.Key_Developer Then
On some Windows8 computers, when trying to preview the report file (open it in the associated application), I get the following error message and the report file will not open; "We're sorry, but Excel has run into an error that is preventing it from working correctly. Excel will need to be closed as a result. Would you like us to repair now?" Same problem with Word.
But, if Excel is opened first and left open, then my application will open the report file without error. I can also use windows explorer and double click to open the file outside of my application without error.
I can also launch the same VB.NET dll via a separate VB.NET UI application and the report file will also without error.
Some additional information:
- vb.net application is compiled to .NET framework 4
- This application is deployed on a number of computers with a mixture of Windows7, 8 and 8.1 and Office 2007 - 2013. Only a handful display this problem.
- User account control is set to lowest setting and user is an administrator
- The VB6 UI executable has been set to run in compatibility mode for Windows XP (SP3)
I'm wondering if someone can tell me or help me figure out what is going on here. I am open to alternate solutions but do not want to hard wire to opening the files using Office DLLs. I want the user to be able to open with what ever word processor or spreadsheet they are using.
Thank you for your time.