Visual Studio Hacks [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

Visual Studio Hacks [Electronic resources] - نسخه متنی

Andrew Lockhart

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
لیست موضوعات
توضیحات
افزودن یادداشت جدید







Hack 83. Install Visual Studio Tools for Office 2003

Office is much more than a spreadsheet, word
processing, database, and presentation tool. It's a
complete platform for developing incredible applications.

Visual
Studio Tools for Office (VSTO) is available as a download for MSDN
subscribers and is also available for purchase. Starting with Visual
Studio 2005, Visual Studio Tools for Office will be included with all
full versions of Visual Studio (except the Express editions).

In order to get started with the VSTO, you will need to install


Microsoft Office Word 2003 or Excel 2003. Now,
these products are still primarily COM-based applications, so you are
going to need to go beyond the standard installation and add the

Primary Interop Assemblies (PIA) to
the installation. The assemblies will be installed only if you chose
to add the .NET programmability support to your installation choices
or if you did a complete installation when you originally installed
Office.


In the following steps, if you perform a custom installation, be sure
to select the .NET Programmability Support under
Excel and/or Word. In addition, select Microsoft Forms 2.0 .NET
Programmability Support under Office Tools and select .NET
Programmability Support under the Microsoft Graph component, which
you will find under the Office Tools node.

If you haven't installed Office 2003 or Visual Studio 2003


Since the PIAs are installed into the Global Assembly Cache
(GAC), you should install the products in the following order:



Microsoft Visual Studio .NET 2003

Microsoft Office System

Visual Studio Tools for the Microsoft Office System


If you have installed Office 2003 but not VS.NET


If you have already completed the install of Office 2003, you will
need to install the products in this order:


If you did not perform a complete installation for Office 2003, you
can add the components noted earlier by using Add/Remove Applications
from the control panel and updating your installation choices for
Microsoft Office System 2003. You will need to have your installation
CD available.

Install Visual Studio .NET, including at least Visual Basic .NET or
Visual C# (or both) and the MSDN product documentation.

Install Visual Studio Tools for the Microsoft Office System.



If you have installed VS.NET but not Office 2003



Install Microsoft Office 2003 (see the previous note if you need a
custom installation).

Install Visual Studio Tools for the Microsoft Office System.



11.2.1. When You Deploy


Once you have completed an application
built on the Microsoft Office System, you will need to deploy the
solution to an end user's computer and install the
following:

Microsoft .NET Framework 1.1

Microsoft Office Excel 2003 and/or Microsoft Office Word 2003,
including the necessary primary interop assemblies



11.2.2. Considerations


Keep the following in mind when developing with the
VSTO.

11.2.2.1 Handling optional parameters


You may find that writing the same applications for the VSTO will
take more effort to accomplish the same task depending on what
language you are using. Take, for
example, the following code to create a new Excel workbook in
VB.NET:

Dim wb As Excel.Workbook = _
ThisApplication.Workbooks.Open("C:\VSHacks\LoanCalc.xls")

However, to accomplish the same thing in
C#, you would need to type the
following:

Excel.Workbook wb = ThisApplication.Workbooks.Open( 
"C:\\VSHacks\\LoanCalc.xls", Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing);

11.2.2.2 Closing the debugger closes Office application


If you are debugging your new Office
application through Visual Studio, you will find that if you close
your document, you will be returned to Visual Studio to continue
working with the code. However, if you close Visual Studio or stop
the execution of your code (by clicking the Stop Debugging button or
pressing Shift-F5), you will also close your Office
applicationany work that you did in your Office document will
not be saved and you won't be prompted to save your
work.

11.2.2.3 COM-based assemblies still return COM-based HResults


Although the .NET Framework will wrap COM-based HResult errors as an
exception, you will find that sometimes the error messages
aren't all that helpful. If you are having
difficulty with a particular procedure, try recording an Office macro
to do the same task and compare your code to the VBA that was created
during the recording of the macro.

Brian Sherwin


/ 172