Start Office File with .NET COM Add-In

M

Michael Cross

Hello NG,

I develop an small COM Add-In for Microsoft Office with Visual Basic
..NET.

With .NET I can start a new process by defining

Dim myProcess As New Process

and using the start-function of this object.

myProcess.Start = ("C:\myExcelSheet.XLS")

Is the Add-In running in a different office application as Excel, it
will start the new Excel process with the loaded Excel sheet.

But if I start the process in an Add-in loaded into excel, the process
will not start.

Does anybody know how to resolve this problem?

Any help is greatly appreciated.

Kind regards,

Michael
 
R

Robert Jacobson

What are you trying to do with your add-in code -- open the document in the
current instance of Microsoft Excel, or open it in a new instance of
Microsoft Excel?

Regardless, you shouldn't be using generic Process commands to do this --
instead, you should be using Excel-specific Automation commands. For
example, once you have an Excel application object, you can use a command
like this to open a workbook:

Dim wb As Excel.Workbook =
ThisApplication.Workbooks.Open("C:\YourPath\YourWorkbook.xls")


Here are some resources to get you started:

Office Development
http://msdn.microsoft.com/vbasic/using/building/office/default.aspx

Understanding the Excel Object Model from a .NET Developer's Perspective
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odc_vsto2003_ta/html/excelobj.asp

INFO: Develop Microsoft Office Solutions with Visual Studio .Net
http://support.microsoft.com/?kbid=311452


Hope this helps,
Robert Jacobson
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top