Hi Jennyfer,
When you open programatically an Office application, assuming that your code
releases all COM references to the Application and the objects that you have
created, the application will be destroyed after the last reference is
released. In .NET is quite easy to get into the opposite problem, see
Office application does not quit after automation from Visual Studio .NET
client
http://support.microsoft.com/default...b;en-us;317109)
but since your intention is to keep the app open, you should use
Application.UserControl = True to increase artificially the number of COM
references. I am assuming that your code Application.Visible = True works
fine but the app is closed so fast that you can´t even see it. You can
verify it inserting a MsgBox just after making it visible.
--
Best regards,
Carlos J. Quintero
MZ-Tools: Productivity add-ins for Visual Studio .NET, VB6, VB5 and VBA
You can code, design and document much faster.
Free resources for add-in developers:
http://www.mztools.com
"Jennyfer Barco" <pd*****@nospam.wdsinc.com> escribió en el mensaje
news:uL**************@TK2MSFTNGP15.phx.gbl...
Hello, I have a question, how can I open Microsoft Excel from .NET. I only
need to open a new file in Excel and paste some information and set the
Microsoft Excel as the enabled aplication, so the user can continue
working in Excel and he'll save the information I pasted. I tried this but
doesn't open Excel at all, but it does save the file c:\test.xls with the
value "This is column B row 2" in colum B and row 2:
Dim xlApp As Interop.Excel.Application
Dim xlBook As Interop.Excel.Workbook
Dim xlSheet As Interop.Excel.Worksheet
xlApp = CType(CreateObject("Excel.Application"),
Interop.Excel.Application)
xlBook = CType(xlApp.Workbooks.Add, Interop.Excel.Workbook)
xlSheet = CType(xlBook.Worksheets(1), Interop.Excel.Worksheet)
' Place some text in the second row of the sheet.
xlSheet.Cells(2, 2) = "This is column B row 2"
' Show the sheet.
xlSheet.Application.Visible = True
' Save the sheet to C:\Test.xls directory.
xlSheet.SaveAs("C:\Test.xls")
Thanks in advance
Jennyfer