Article ID: 311452 - Last Review: May 9, 2007 - Revision: 10.13 INFO: Develop Microsoft Office solutions with Visual Studio .NETThis article was previously published under Q311452 On This PageSUMMARY This article is a resource for developers who work in
Microsoft Visual Studio .NET to build solutions using the Microsoft Office
family of products. This article supplements the Microsoft Developer Network
(MSDN) content for Office Development with Visual Studio 6.0, which covers a
much broader scope of development options. This article provides a rudimentary guide to quickly transition developers who are already familiar with Office development in Visual Studio 6.0 to perform the same tasks using Visual Studio .NET. It provides samples and points out any known problems and issues that you may experience when you work with Microsoft .NET. ContentsMORE INFORMATIONIntroductionThe Microsoft Office family of products (including Access, Excel, MapPoint, Outlook, PowerPoint, Project, Visio, and Word) encompasses a wide range of productivity software that is designed for both corporate and small business users. As a suite of end-user tools, Office can aid in the efficient creation, sharing, and managing of your business information. Office can also help you to tailor the product to your organization, or to take advantage of Office technology to solve a particular issue.Office development with Visual Studio .NETThere are a number of different ways to programmatically extend, to automate, to integrate, or to use Office in your development solution. If you are new to developing solutions with Office, see the MSDN Web site in the "Summary" section of this article, which covers many different forms of Office development and lists articles that are specific to each topic.When you decide which type of Office development that you have to do, the next step is to decide what development tool to use. The purpose of this article is to discuss how to build Office solutions in Visual Studio .NET. It covers both unmanaged languages such as Microsoft Foundation Classes (MFC) and Active Template Library (ATL), and managed languages such as Visual Basic .NET and Visual C#. Which language you select depends on your project, your resources, and your familiarity with a particular language. Microsoft has authored a number of Knowledge Base articles that show you how to perform common Office tasks in Visual Studio .NET. Because there are many articles, the purpose of this article is to help to organize that content, and to give you the important information that you must have to troubleshoot and to program more effectively when you work in .NET. Important feature changes with the .NET FrameworkMost developers who use Visual Studio .NET want to develop in languages that are closely tied to the Microsoft .NET Framework. There are some important changes to note when you use the .NET Framework with Office development. If you code in Visual Basic, Visual C#, or a third-party managed language for .NET, be familiar with these changes to know how you might have to structure your Office solution.Note This section applies to managed languages only. If you are working in MFC or ATL, you can safely skip this section unless you plan to use Visual C++-managed extensions somewhere in your project. Read the following section if you are unfamiliar with the differences between managed and unmanaged languages. The .NET Framework is about managed code. Managed code is code that is object-oriented, type-safe, memory-managed, secure, and (most of all) portable. This code is compiled on demand (or during install) from its native form, which is named Intermediate Language (IL), to machine code that can actually run on the processor. Additionally, Microsoft has defined a set of classes (with namespaces) that make up the runtime environment for managed code, which is named the common language runtime. The common language runtime is the programming backbone of any managed language in .NET, and gives you control over all of the elements that you must have to make your program. Programs that are written with the .NET Framework are inherently safer to run, because they are more stable and securable than earlier programs. However, this power and flexibility comes at a price. The price is that there are structural differences in how the code is managed by the common language runtime. For developers who are familiar with Office development in Visual Studio 6.0, consider the following five important feature changes, and the effects that these feature changes have on your project:
With these issues in mind, you can better approach the differences when you perform Office development in Visual Studio .NET compared to Visual Studio 6.0. Automation of Office from Visual Studio .NETAutomating Microsoft Office is a convenient and flexible way to incorporate Office functionality into your custom solution. While future versions of Office will integrate with the .NET Framework, the current and past versions of Office do not. Much of what you must do to automate Office remains the same as what you did in Visual Studio 6.0. Office is COM based, so you must use COM to programmatically make changes to Office. Some of the details have changed, but the overall approach has not.To automate Microsoft Office Applications from Visual Studio .NET, you will need to download and install the Primary Interop Assemblies (PIAs) for Microsoft Office XP. For more information about Office XP PIAs, click the following article number to view the article in the Microsoft Knowledge Base: 328912
(http://support.microsoft.com/kb/328912/
)
INFO: Microsoft Office XP PIAs are available for download
Developers who work with the PIAs for Office XP must be aware that the assemblies are slightly different from the Office object model. Therefore, you may have to make code changes if you are porting an existing application. Additionally, the PIAs exhibit behavior that is consistent with .NET as follows:
http://msdn.microsoft.com/en-us/library/aa163989.aspx (http://msdn.microsoft.com/en-us/library/aa163989.aspx) When you work on an Office Development solution, the first question you must ask is which versions of Office does this project have to work with? Compatibility is an important issue, and if you need your code to work with specific versions, you must do as much of your development and initial testing with the earliest version of Office that you need your code to be compatible with. For example, if you need a project that works with Office 2000 and later, use Office 2000 (and the Office 2000 type libraries) during your development. This way you can make sure that your project can run with Office 2000 and later (but not necessarily with Office 97). For more information, click the following article number to view the article in the Microsoft Knowledge Base: 244167
(http://support.microsoft.com/kb/244167/
)
INFO: Writing Automation clients for multiple office versions
When you decide which versions of Office that you
must work with, you must consider how you want to perform Automation in Visual
Studio .NET:
Automation using unmanaged code (Microsoft Foundation Classes (MFC) and Active Template Library (ATL))You can build unmanaged COM clients and servers with Visual C++ .NET just as you would in previous versions of Visual C++. The MFC and ATL frameworks have not substantially changed in regards to COM or OLE, so your existing code that uses Office Automation can be ported to Visual C++ .NET with very little trouble. Moreover, the manner in which you perform Automation (using MFC wrapper classes or #import) is similar to what you are already familiar with; therefore, there are no new technologies to learn.Create class wrappers in MFC The only real change for developers who are accustomed to working with MFC is the removal of ClassWizard for the Visual Studio IDE. This change effects how you create your MFC class wrappers for an Office application if you start a new project. For more information about how to create a new set of MFC wrapper classes from a type library in Visual C++ .NET, click the following article number to view the article in the Microsoft Knowledge Base: 307473
(http://support.microsoft.com/kb/307473/
)
How to use a Type library for Office Automation from Visual C++ .NET
The resulting wrapper classes work much the same as
those classes that are made by Visual Studio 6.0. You can expect Visual Studio
.NET to create a separate file for each imported class. There are also some
problems with the new class generator when you work with Office type
libraries. For more information about these issues and the steps to
take to avoid them, click the following article numbers to view the articles in
the Microsoft Knowledge Base: 311407
(http://support.microsoft.com/kb/311407/
)
BUG: MFC Class Wizard does not resolve naming conflicts between Windows APIs and COM interface methods
311408
(http://support.microsoft.com/kb/311408/
)
BUG: 'Read-Only' warning when adding an MFC Class from a Type Library
Automation samples Using MFC For additional information about how to automate Office from Visual Studio .NET in MFC, click the article numbers below to view the articles in the Microsoft Knowledge Base: Microsoft Excel 308292
(http://support.microsoft.com/kb/308292/
)
How to automate excel to create and format a new Workbook by using C++ .NET and MFC
308407
(http://support.microsoft.com/kb/308407/
)
How to automate Excel from C++ .NET and MFC to fill or obtain data in a range using arrays
309301
(http://support.microsoft.com/kb/309301/
)
How to handle events for Excel by using Visual C++ .NET
Microsoft Word308338
(http://support.microsoft.com/kb/308338/
)
How to automate Microsoft Word to perform a mail merge from Visual C++ .NET
309294
(http://support.microsoft.com/kb/309294/
)
How to handle Word events by using Visual C++ .NET and MFC
Microsoft PowerPoint308336
(http://support.microsoft.com/kb/308336/
)
How to use automation to create and show a PowerPoint presentation with Visual C++ .NET and MFC
309309
(http://support.microsoft.com/kb/309309/
)
How to handle PowerPoint events by using Visual C++ .NET and MFC
Shared Office features306686
(http://support.microsoft.com/kb/306686/
)
How to run Office Macros by using automation from Visual C++ .NET
312626
(http://support.microsoft.com/kb/312626/
)
How to use automation to create Office command bars and controls by using Visual C++ .NET
310744
(http://support.microsoft.com/kb/310744/
)
How to dismiss a dialog box displayed by an Office application by using Visual C++ .NET and MFC
Automation using managed code (Visual Basic or Visual C#)Automation of Office from managed code is a little different from earlier Visual Basic programming. When you Automate in a managed language, you do not directly bind to the object. Your communication passes through an intermediate "wrapper" that translates native .NET data types and calls into COM types and calls (and vice versa).COM interoperability in .NET The COM Interop services of the common language runtime allow managed code that runs in .NET to communicate with earlier COM servers (such as Office) by using a wrapper between your managed code and the COM server. The wrapper is named an Interop Assembly. When you add a reference to a COM server (for example, its type library) in your .NET project, Visual Studio .NET uses the type information to generate code for a Runtime Callable Wrapper (RCW) which is then imported into your project. This managed code is compiled into a separate assembly (that is, the Interop Assembly), and is accessed by the .NET Framework as if it was any other .NET managed library. The RCW acts as the middle-man between your managed code and the COM server. If a COM server is written to be .NET-aware, it can provide a Primary Interop Assembly (PIA) that is installed, and then is registered in the global assembly cache. These assemblies are shared, and are considered the best way to reference an earlier COM server in a .NET project. Currently, Microsoft provides PIAs for Office XP (and newer versions) only. These PIAs are available for download now, and can be redistributed with your project. For more information about Office XP PIAs, click the following article number to view the article in the Microsoft Knowledge Base: 328912
(http://support.microsoft.com/kb/328912/
)
INFO: Microsoft Office XP PIAs are available for download
If your project calls for Automation to Office
2000, you must create your own Interop Assemblies (IAs) for Office/MSO, VBA
Extensibility, and the Office application you want to automate. These custom
IAs should be treated as a part of your application, and deployed to your
application folder with the rest of your project. Although Visual Studio .NET
can automatically make these assemblies for you by using the Tlbimp.exe
utility, they are your custom assemblies, and should not be registered in the
global assembly cache as global objects.For additional information about COM Interop in .NET, see the COM Interop section in the Microsoft Developer Network (MSDN) Library at the following MSDN Web site:
Advanced COM Interop Documentation (MSDN Online Library) http://msdn2.microsoft.com/en-us/library/bd9cdfyx(vs.71).aspx (http://msdn2.microsoft.com/en-us/library/bd9cdfyx(vs.71).aspx) Bind to Office applications from your runtime callable wrapper (RCW) The Interop Assembly that you make from a type library uses early binding to communicate with the COM object. However, if you must keep the binding details generic (for example, if you need the code to Automate more than one type of Office application, but do not have to know which type explicitly), you can still do late binding in Visual Studio .NET. For more information about binding choices in .NET, click the following article numbers to view the articles in the Microsoft Knowledge Base: 304661
(http://support.microsoft.com/kb/304661/
)
How to use Visual Basic .NET for binding for Office Automation servers
302902
(http://support.microsoft.com/kb/302902/
)
HOW TO: Binding for Office automation services with Visual C# .NET
The advantage of late binding is that you do not
have to use an RCW (or build/ship a custom Interop Assembly), and it is more
version agnostic. The disadvantage is that it is more difficult to do this in
Visual Basic .NET than it is in Visual Basic 6.0, and late binding still
suffers the performance hit of having to find DISPIDs at runtime.In additional to binding, another issue of importance is object instantiation. If you use an Interop Assembly, the RCW for the specific Office Application controls object instantiation when you use the New operator. Behind the scenes, the RCW calls the appropriate COM routine (for example, CoCreateInstance) to make a new instance of that application for your code to use. If you want to explicitly control object instantiation or bind to an already running instance of the application, you can use GetObject in Visual Basic .NET, or GetActiveObject in Visual C#. However, Office applications only register themselves in the Running Object Table (ROT) if they have gained and lost focus at least one time. If you are doing this in code, timing and focus are going to be big issues for your code to work. For more information, click the following article numbers to view the articles in the Microsoft Knowledge Base: 316126
(http://support.microsoft.com/kb/316126/
)
How to use Visual C# .NET to automate a running instance of an Office program
316125
(http://support.microsoft.com/kb/316125/
)
Visual C# .NET error attaching to running instance of Office application
308409
(http://support.microsoft.com/kb/308409/
)
Visual Basic .NET error using GetObject or GetActiveObject for running instance of Office application
Handle events from the RCW The .NET Framework supports type safe, callback function pointers to invoke notification messages back to single client (such as a typical COM event) or to multiple clients (such as an asynchronous broadcast). The .NET object that handles this callback mechanism is called a Delegate, and for developers familiar with COM, consider Delegates as a way to handle COM events (although they can be used for other purposes). When you make an RCW from a type library, any event methods that are described in the library are wrapped to form a Delegate class that you can use to handle the event. To sink an event, you implement the function to handle the event, make an instance of the delegate that is bound to that function, and then attach the delegate to the object that you want to receive events from. The following is an example: 302814
(http://support.microsoft.com/kb/302814/
)
How to handle events for Excel by using Visual Basic .NET
If the RCW does not have a delegate for the event
method that you want, if you have to provide for callbacks dynamically, or if
you have to change them based on other considerations, you must use the COM IConnectionPoint and IConnectionPointContainer interfaces to set up your own sink. It is more work, but it may
the only way to reliably sink events for some servers.
For more information, click the following
article number to view the article in the Microsoft Knowledge Base: 308330
(http://support.microsoft.com/kb/308330/
)
How to handle PowerPoint events with Visual Basic .NET
Automation samples using managed code (Visual Basic or Visual C#) For additional information about working in .NET, click the article numbers below to view the articles in the Microsoft Knowledge Base: Microsoft Excel 301982
(http://support.microsoft.com/kb/301982/
)
How to automate Microsoft Excel from Visual Basic .NET
302084
(http://support.microsoft.com/kb/302084/
)
How to automate Microsoft Excel from Microsoft Visual C# .NET
302814
(http://support.microsoft.com/kb/302814/
)
How to handle events for Excel by using Visual Basic .NET
302815
(http://support.microsoft.com/kb/302815/
)
How to handle events for Excel by using Visual C# .NET
302094
(http://support.microsoft.com/kb/302094/
)
How to automate Excel from Visual Basic .NET to fill or obtain data in a range using arrays
302096
(http://support.microsoft.com/kb/302096/
)
How to automate Excel with Visual C# .NET to fill or obtain data in a range using arrays
306022
(http://support.microsoft.com/kb/306022/
)
How to transfer data to an Excel workbook by using Visual Basic .NET
306023
(http://support.microsoft.com/kb/306023/
)
How to transfer data to an Excel workbook by using Visual C# .NET
307021
(http://support.microsoft.com/kb/307021/
)
How to transfer XML data to Microsoft Excel 2002 by using Visual Basic .NET
307029
(http://support.microsoft.com/kb/307029/
)
How to transfer XML data to Microsoft Excel 2002 by using Visual C# .NET
Microsoft Word316383
(http://support.microsoft.com/kb/316383/
)
How to automate Word from Visual Basic .NET to create a new document
316384
(http://support.microsoft.com/kb/316384/
)
How to automate Word from Visual C# .NET to create a new document
301656
(http://support.microsoft.com/kb/301656/
)
How to automate Microsoft Word to perform a mail merge from Visual Basic .NET
301659
(http://support.microsoft.com/kb/301659/
)
How to automate Microsoft Word to perform mail merge from Visual C# .NET
302816
(http://support.microsoft.com/kb/302816/
)
How to handle events for Microsoft Word using Microsoft Visual Basic .NET
302817
(http://support.microsoft.com/kb/302817/
)
How to handle events for Word using Visual C# .NET
Microsoft PowerPoint303717
(http://support.microsoft.com/kb/303717/
)
How to use automation to create and show a PowerPoint presentation with Visual Basic .NET
303718
(http://support.microsoft.com/kb/303718/
)
How to use automation to create and show a PowerPoint presentation with Visual C# .NET
308330
(http://support.microsoft.com/kb/308330/
)
How to handle PowerPoint events with Visual C# .NET
308825
(http://support.microsoft.com/kb/308825/
)
How to handle PowerPoint events with Visual C# .NET
Microsoft Access317113
(http://support.microsoft.com/kb/317113/
)
How to automate Microsoft Access from Visual Basic .NET
317114
(http://support.microsoft.com/kb/317114/
)
How to automate Microsoft Access from Visual C# .NET
Microsoft Visio305199
(http://support.microsoft.com/kb/305199/
)
How to automate Visio with Visual Basic .NET
Microsoft MapPoint305200
(http://support.microsoft.com/kb/305200/
)
How to automate MapPoint by using Visual Basic .NET
302897
(http://support.microsoft.com/kb/302897/
)
How to automate MapPoint 2002 Control and save the map as HTML in Visual Basic .NET
Shared Office features303017
(http://support.microsoft.com/kb/303017/
)
How to use automation to create Office command bars and controls with Visual Basic .NET
303018
(http://support.microsoft.com/kb/303018/
)
How to use automation to create Office command bars and controls with Visual C# .NET
302281
(http://support.microsoft.com/kb/302281/
)
How to obtain the Window handle for an Office automation server using Visual Basic .NET
302295
(http://support.microsoft.com/kb/302295/
)
How to obtain the Window handle for an Office automation server using Visual C# .NET
306682
(http://support.microsoft.com/kb/306682/
)
How to run Office macros using automation from Visual Basic .NET
306683
(http://support.microsoft.com/kb/306683/
)
How to run Office Macros using automation from Visual C# .NET
303294
(http://support.microsoft.com/kb/303294/
)
How to use automation to get and set Office document properties with Visual Basic .NET
303296
(http://support.microsoft.com/kb/303296/
)
How to use automation to get and set Office document properties with Visual C# .NET
307292
(http://support.microsoft.com/kb/307292/
)
How to dismiss a dialog box displayed by an Office application with Visual Basic .NET
Known issues with automation from managed code Because the common language runtime uses a garbage collector for memory management, and because your RCW is itself a managed object, the lifetime of your Automation object is not guaranteed to end in a deterministic fashion as soon as you release your reference to it. The RCW is marked for garbage collection and is released when the garbage collector wants to free more memory. This means that although you are no longer automating an Office application, the application may stay loaded because the garbage collector has not yet freed the RCW. For more information, click the following article number to view the article in the Microsoft Knowledge Base: 317109
(http://support.microsoft.com/kb/317109/
)
PRB: Office application does not quit after automation from Visual Studio .NET client
For more
information about problems you may experience when you work with Office objects
from managed code, click the following article numbers to view the articles in
the Microsoft Knowledge Base: 315981
(http://support.microsoft.com/kb/315981/
)
Visual Basic .NET "[Method] is ambiguous across the inherited interfaces" error message when using Office Automation
316653
(http://support.microsoft.com/kb/316653/
)
PRB: Error using WithEvents or Delegates to handle Excel events from Visual Basic .NET or Visual C# .NET
320369
(http://support.microsoft.com/kb/320369/
)
BUG: Old format or invalid type library error when automating Excel 2002
317157
(http://support.microsoft.com/kb/317157/
)
PRB: Errors when you reference the Access 10.0 type library with Visual Studio .NET
Office Web solutions with ASP.NETASP.NET is the new development platform in Visual Studio .NET that allows developers to create enterprise-class applications. ASP.NET allows you to develop Web applications in any .NET-enabled language and to take advantage of the rich functionality of the .NET Framework. ASP.NET Web forms allow you to build user interfaces for your Web applications. Although Web forms provide a user interface for your Web applications, the code-behind (code that runs to produce output for your page) for the page is still run on the server computer. Microsoft does not recommend that you automate the Office products from a Web Form, or that you automate from other non-interactive accounts. For more information, click the following article number to view the article in the Microsoft Knowledge Base:257757
(http://support.microsoft.com/kb/257757/
)
INFO: Considerations for server-side automation of Office
Other approaches to server-side automation include
client-side automation, streaming Multipurpose Internet Mail Extension (MIME)
content, and the Office Web Components. Each of these methods is described in
the following section.Use Office Web components in ASP.NETOffice Web Components (OWC) provide the best means to include Office functionality in your Web project. The components can be used in ASP.NET as client-side controls as they would be from any HTML page. Additionally, OWC 10 (Office XP) provides reasonable functionality to make it a good server-side component for limited size Web sites. For more information about how OWC 10 may be used in a server-side solution from ASP.NET, click the following article number to view the article in the Microsoft Knowledge Base:303016
(http://support.microsoft.com/kb/303016/
)
How to use a dataset with the Office XP chart component and ASP.NET
315695
(http://support.microsoft.com/kb/315695/
)
How to use the Office XP Web components with XML data generated by an XML Web service created using ASP.NET
Use Document Streaming from ASP.NETIf the Office Web Components do not have the functionality that you need, you can configure the HTML page to start the Office application on the client computer, and then to load the data from a Web server. The user can then use the full power of Office to modify, to edit, or to save the data that you returned.You can use several methods to return Data to the client, including XML Web services and MIME content. The integration of XML Web services is a new addition to Visual Studio .NET. Visual Studio .NET allows developers to easily create and to consume XML Web services. XML Web services provide services to users through a standard Web protocol. Users can use a Visual Studio .NET application, or use the Microsoft SOAP Toolkit to connect to XML Web services. For additional information about the Soap Toolkit, visit the following Microsoft Developer Network (MSDN) Web site: http://msdn.microsoft.com/en-us/library/aa286526.aspx
(http://msdn.microsoft.com/en-us/library/aa286526.aspx)
Additionally, the Office XP Web Services Toolkit allows
developers to reference an XML Web service directly from VBA without using the
.NET Framework.Another method to send data to a client computer is to stream the content by using MIME types. When you change the MIME type for a Web page to a specific value, the browser starts the associated application that displays the data. When you use this method, any type of data that can open in the Office application (such as Rich Text Format (RTF), HTML, and binary data) can be sent to the client after you set the content type. Because ASP.NET Web Controls generate HTML that is sent to the client, the content type for the Web page can be set to display the contents of the controls in the Office applications. For more information, click the following article numbers to view the articles in the Microsoft Knowledge Base: 318425
(http://support.microsoft.com/kb/318425/
)
How to send and receive binary documents by using an ASP.NET Web service and Visual C# .NET
318756
(http://support.microsoft.com/kb/318756/
)
PRB: Excel and Word content do not stream as expected from ASP.NET
311461
(http://support.microsoft.com/kb/311461/
)
How to use ASP.NET or Visual Basic .NET to Transform XML to rich text format (RTF) for Microsoft Word 2002
319180
(http://support.microsoft.com/kb/319180/
)
How to transform a dataset to spreadsheet XML for Excel by using Visual Basic .NET and ASP.NET
317719
(http://support.microsoft.com/kb/317719/
)
How to export data in a datagrid on an ASP.NET Webform to Microsoft Excel
316934
(http://support.microsoft.com/kb/316934/
)
How to use ADO.NET to retrieve and modify records in an Excel workbook with Visual Basic .NET
307033
(http://support.microsoft.com/kb/307033/
)
How to use an XML Web service by using ASP.NET from an Office VBA macro in Word or Excel
Office extensibility using Visual Studio .NETBuilding extensible components to run inside Office has always been an important part of Office development. Both Office 2000 and Office XP allow for the programmatic extension of the host application by using COM add-ins. Office XP introduces capabilities to extend the document content through the use of a SmartTag Recognizer or an Action component. Because both of these solutions are heavily rooted in COM, consider the advantages of using a fully compiled COM component before you decide to build one in Visual Studio .NET.However, if your design calls for using .NET features, or it can otherwise benefit from using .NET, you can create both types of add-ins in Visual Studio .NET. Developers who are familiar with how COM add-ins or SmartTags worked in Visual Studio 6.0 must keep the following in mind:
COM add-insCOM add-ins are the most common type of extensibility solution that is used by developers. To fully integrate the add-in with the host application, developers have to automate the add-in from the application. For this reason, it is important that developers are familiar with the Automation of Office from Visual Studio .NET section earlier in this article.For more information about how to provide the groundwork to make a COM Add-in in Visual Studio .NET, click the following article numbers to view the articles in the Microsoft Knowledge Base: 302896
(http://support.microsoft.com/kb/302896/
)
How to build an Office COM add-in by using Visual Basic .NET
302901
(http://support.microsoft.com/kb/302901/
)
How to build an Office COM by using Visual C# .NET
316723
(http://support.microsoft.com/kb/316723/
)
PRB: Visual Studio .NET shared add-in is not displayed in Office COM add-ins dialog box
Smart tagsSmart Tags are a new technology that are introduced with Office XP. Smart Tags offer a new type of interaction with your documents. Currently, Smart Tags only work with Microsoft Word 2002 and Microsoft Excel 2002. For additional information about Smart Tags, see the Smart Tag Software Development Kit (SDK) at the following Microsoft Developer Network (MSDN) Web site:Microsoft Smart Tag SDK
(http://www.microsoft.com/downloads/details.aspx?familyid=3d8edcee-0246-43ef-a70f-94c0899f1e8f&displaylang=en)
For more information about how
to develop a SmartTag add-in using Visual Studio .NET, click the following
article numbers to view the articles in the Microsoft Knowledge Base: 306058
(http://support.microsoft.com/kb/306058/
)
How to create an Office XP smart tag DLL by using Visual Basic .NET
306422
(http://support.microsoft.com/kb/306422/
)
How to create an Office XP smart tag DLL by using Visual C# .NET
Office security and managed codeBecause managed code is not native, the COM registry entries made for an Office component that you build with .NET point to the .NET runtime engine (mscoree.dll) and not your assembly. Because mscoree.dll is not digitally signed and Office determines whether an add-in is safe based on a digital signature, your users may receive a macro warning dialog box that prompts them to enable or disable your add-in, even if you digitally signed for your assembly.316724
(http://support.microsoft.com/kb/316724/
)
PRB: "Mscoree.dll contains macros" prompt when starting Office application
To avoid this macro warning, you can use a "shim"
for your component. For additional information about developing and deploying a
shim solution, see the following articles on the Microsoft Developer Network
(MSDN) Web site:
Deployment of Managed COM Add-Ins in Office XP http://msdn2.microsoft.com/en-us/library/aa164016(office.10).aspx (http://msdn2.microsoft.com/en-us/library/aa164016(office.10).aspx) Using the Smart Tag Shim Solution to Deploy Managed Smart Tags in Office XP http://msdn2.microsoft.com/en-us/library/aa163615(office.10).aspx (http://msdn2.microsoft.com/en-us/library/aa163615(office.10).aspx) Using the COM Add-in Shim Solution to Deploy Managed COM Add-ins in Office XP http://msdn2.microsoft.com/en-us/library/aa140200(office.10).aspx (http://msdn2.microsoft.com/en-us/library/aa140200(office.10).aspx) OLE documents And storageVisual Studio .NET does not provide any new functionality for editing or viewing Office documents inside a Windows application. In fact, for some developers who are familiar with Visual Basic, it may appear like a step back because you no longer have the familiar OLE Container Control. For more information, click the following article number to view the article in the Microsoft Knowledge Base:304562
(http://support.microsoft.com/kb/304562/
)
INFO: Visual Studio .NET does not provide an OLE container control for Win Forms
However, there is a reason for this. OLE is
COM-based, and .NET is not. To live up to the cross-platform design for the
common language runtime, OLE solutions cannot be tightly bound to the
framework. If your solution requires OLE capabilities, you can use the
WebBrowser control or a custom-built OLE Document viewer.
For more
information, click the following article numbers to view the articles in the
Microsoft Knowledge Base: 304643
(http://support.microsoft.com/kb/304643/
)
How to use the WebBrowser control to open an Office document in Visual Basic .NET
304662
(http://support.microsoft.com/kb/304662/
)
How to use the WebBrowser control to open Office documents with Visual C# .NET
311765
(http://support.microsoft.com/kb/311765/
)
SAMPLE: Visual C++ ActiveX control for hosting Office documents in Visual Basic or HTML
For more information about how to
use the existing OLE features in an unmanaged MFC or ATL project to build your
solution, click the following article numbers to view the articles in the
Microsoft Knowledge Base: 316587
(http://support.microsoft.com/kb/316587/
)
How to automate embedded Office ActiveX documents with C++ .NET
316207
(http://support.microsoft.com/kb/316207/
)
How to embed and automate a Word document by using C++ .NET and MFC
APPLIES TO
| Article Translations
|
Back to the top
