Visual studio tools para office system 2003




















These variables are references to the current document and application. One last thing to note is how your project links to the workbook or document defined in the wizard. Figure 3 shows the Project Properties dialog box and how the Visual Studio.

NET project is linked to Word and the specified document. Figure 4 shows the Properties dialog box from Word and how the document is linked to a. NET assembly. As you can see, the interface is pretty simple for interacting with Office applications from Visual Studio. Now let's go to work and make this thing do something. No article on using a new technology would be complete without a new-fangled Hello World example. From this code, you can see that you are adding text to the Range object of the Word document.

Not too difficult, is it? The next step is to create an application that deals with more complex code and issues than Hello World. One of the great things about Visual Studio. NET is its ability to create and consume Web services. It would be nice to take advantage of this in your Word applications as well. That's what this next set of code will do. The interface is pretty simple for interacting with Word and Excel applications from Visual Studio.

The WebMethod returns the city and state for a passed-in Zip Code. Next, you'll add some data entry controls to your Word document. These data entry controls are:. You can add these controls to your Word document via the Control Toolbox in Word Your Word document should look like the document in Figure 5. Now that you have created your Word document with the proper controls, you can create your Web service, adding code to the interface with controls and adding code to call the Web service.

Add the following code to your Web service:. Build the Web service by pressing F5. You can now return to your. The next step is to add code to interface with the controls you added to your Word document. This is a multi-step process:. The first step to integrating with the Microsoft Forms 2. To do this, right click on the References section of the Solutions Explorer and then choose References from the shortcut menu.

You can now use this library in your applications. The next step is to add an Imports statement to the top of your class. The following code adds the Forms library to your class:. As you can see, this library is imported and aliased to the name myForms. This is a cool.

NET feature that allows you to import a library and access its properties and classes via an alias. The next step is to add Reference properties to the controls on your Word document.

The following code adds reference properties for each control:. One item to note is the inclusion of the WithEvents option. These controls send events to your. NET code, which requires use of the WithEvents option.

After adding the reference variables to your code, you need to cast these controls as the proper object types. The following code uses the FindControl which can be found in the code created by the Office Project Wizard and the Ctype function to cast the reference properties as the proper object types:.

The Ctype function is used to cast an object from one type to another. The FindControl call returns a handle to the object you wish to cast. The final step in this process is to add code to your class to trap the Click event sent from the button on your Word document. To do this, add the following code to your class:. Learn more. Ask Question. Asked 11 years, 11 months ago. Active 8 years, 5 months ago. Viewed 2k times. I have seen conflicting information about this. Improve this question. Community Bot 1 1 1 silver badge.

I may be missing something here, but assuming you could have both versions of office on your machine, what would you expect to happen when you debug your project? Which version of the office app should start? When I setup the app I target it to a specific version of Office using one of the built-in templates, so I would like it to be able to debug the one that it was built with.

In theory it is using the local copies of the pia not the ones in the gac so it could work probably. My understanding is that having both versions causes problems but I haven't tried it myself. Mathias, I think you have the issue the wrong way around. When you debug an Office application you start eg Excel and just attach to that process or setup your project to start an. Add a comment. Active Oldest Votes. Improve this answer. Todd Main Todd Main In order to target to a version I think you need that version installed eg: to target you need installed.

If I can't have both Office versions installed on the same development computer how can I target both versions? Yeah, this can get confusing. For more information, see Visual Studio Tools for Office runtime installation scenarios. Interested in developing solutions that extend the Office experience across multiple platforms? Check out the new Office Add-ins model.

You need to install the Visual Studio Tools for Office runtime on a server. For example, you want to use the ServerDocument class to manage document-level solutions on a server.

You need to install the runtime on a computer that already has all the other prerequisites for Office solutions installed. You must be an administrator on the development computer to install the.

To download the. NET Framework 4, see Microsoft. NET Framework 4. You can download these setup files from Visual Studio Tools for Office runtime.



0コメント

  • 1000 / 1000