Presentation is loading. Please wait.

Presentation is loading. Please wait.

Microsoft Visual Basic 2005 ENRICHMENT CHAPTER Visual Studio Tools for Office.

Similar presentations


Presentation on theme: "Microsoft Visual Basic 2005 ENRICHMENT CHAPTER Visual Studio Tools for Office."— Presentation transcript:

1 Microsoft Visual Basic 2005 ENRICHMENT CHAPTER Visual Studio Tools for Office

2 E Enrichment Chapter: Visual Studio Tools for Office2 Objectives ►Use Visual Studio Tools in Microsoft Word ►Create a VSTO Word template ►Add a DateTimePicker object to an application ►Add a table to a Word document

3 E Enrichment Chapter: Visual Studio Tools for Office3 Objectives ►Add the Actions Pane Control ►Place a ComboBox object in applications ►Calculate payments using the Pmt Function ►Use Math Class methods in mathematical computations

4 E Enrichment Chapter: Visual Studio Tools for Office4 Chapter Project

5 E Enrichment Chapter: Visual Studio Tools for Office5 Chapter Project

6 E Enrichment Chapter: Visual Studio Tools for Office6 Programming an Office Document ►Visual Studio Tools for Office (VSTO, pronounced “visto”) helps you build a Word document or an Excel spreadsheet that contains VB code, allowing you to create automated, customized Office documents that combine the power of Visual Basic with the familiarity of Office ►Working with Office 2003 documents in VSTO is similar to working with a Visual Basic Windows application ►When you create your first VSTO application, you indicate whether you intend to create a Word or Excel document or template A template is a special type of Office file that determines the basic structure for a document and can hold text, styles, macros, keyboard shortcuts, custom toolbars, AutoText entries, and other settings

7 E Enrichment Chapter: Visual Studio Tools for Office7 Creating a VSTO Project ►Start Visual Studio and click the New Project button on the Standard toolbar. In the New Project dialog box, click Office in the Project types list on the left side of the window. In the Templates section, click Word Template. In the Name text box, type VehicleSalesContract ►Click the OK button in the New Project dialog box ►VSTO can place objects on a new or existing Word document. In this example, if necessary click the Create a new document option button. Click the OK button in the Wizard window

8 E Enrichment Chapter: Visual Studio Tools for Office8 Creating a VSTO Project

9 E Enrichment Chapter: Visual Studio Tools for Office9 Understanding VSTO Toolbars and Menus

10 E Enrichment Chapter: Visual Studio Tools for Office10 Using the VSTO Toolbox

11 E Enrichment Chapter: Visual Studio Tools for Office11 Adding a DateTimePicker Object ►The DateTimePicker object allows the user to select one date from a calendar of dates or times

12 E Enrichment Chapter: Visual Studio Tools for Office12 Adding a DateTimePicker Object

13 E Enrichment Chapter: Visual Studio Tools for Office13 Adding a Table to a Word Document ►Click the Insert Table button on the Word Standard toolbar ►Drag to select one row and three columns in the grid ►Release the mouse button to insert the table in the Word template

14 E Enrichment Chapter: Visual Studio Tools for Office14 Inserting a Picture and Additional Cells in the Table ►Click the leftmost cell in the table. Click Insert on the menu bar, point to Picture on the Insert menu, and then click From File. In the Insert Picture dialog box, locate the car.jpg image file where you saved it. Select the car.jpg image and then click the Insert button to place the image in the table ►The second and third columns contain one row. To add rows to these columns, first drag across the second and third columns to select them ►Click Table on the menu bar and then click Split Cells on the Table menu ►In the Split Cells dialog box, use the arrows to set the value in the Number of columns list to 2 and the value in the Number of rows list to 6. Click the OK button in the Split Cells dialog box. Click outside the table

15 E Enrichment Chapter: Visual Studio Tools for Office15 Inserting a Picture and Additional Cells in the Table

16 E Enrichment Chapter: Visual Studio Tools for Office16 Using AutoFormat to Format a Table ►Click anywhere in the table ►Click Table on the menu bar and then click Table AutoFormat. When the Table AutoFormat dialog box opens, click the Table Columns 1 table style. At the bottom of the dialog box, uncheck the Heading Rows, First Column, Last Row, and Last Column boxes in the Apply special formats to section ►Click the Apply Button

17 E Enrichment Chapter: Visual Studio Tools for Office17 Using AutoFormat to Format a Table

18 E Enrichment Chapter: Visual Studio Tools for Office18 Adding the Actions Pane Control ►The Actions Pane Control is a customizable task pane that appears in the Office application window ►Using VSTO, you can create a customized Actions Pane Control called the Document Actions task pane ►The ActionsPane object acts as a container for Visual Basic objects

19 E Enrichment Chapter: Visual Studio Tools for Office19 Adding the Actions Pane Control ►Open the code window by clicking the View Code button on the Solution Explorer toolbar. Click inside the ThisDocument_Startup event ►Type me.act to use IntelliSense to complete the object name ActionsPane. Using IntelliSense, add the statements.Controls.Add(New DateTimePicker). Press the ENTER key and then delete the blank line ►Test the application by clicking the Start Debugging button on the Standard toolbar

20 E Enrichment Chapter: Visual Studio Tools for Office20 Adding the Actions Pane Control

21 E Enrichment Chapter: Visual Studio Tools for Office21 Adding the Actions Pane Control ►Click Project on the menu bar and the click Add New Item on the Project ►Click Actions Pane Control ►Click the Add button in the Add New Item dialog box

22 E Enrichment Chapter: Visual Studio Tools for Office22 Adding the Actions Pane Control ►Drag a Label object from the Toolbox to the Actions Pane Control. Change the (Name) property of the Label object to lblCalculator. Change the Text property to Loan Calculator, and the Font property to Sans Serif, size 12 ►To display the Actions Pane Control when the application runs, you must code a request to view the Document Actions task pane that is executed when the Word document opens. Click the ContractDocument.vb tab to open the code window for the Word template. Click in the ThisDocument_Startup event, type me.act and use IntelliSense to complete the rest of the line of code shown in Figure EC-32 on page 668, which opens the Actions Pane Control when the application begins ►Click the Start Debugging button on the Standard toolbar to execute the application. Microsoft Word opens with the Document Actions task pane on the right side of the window

23 E Enrichment Chapter: Visual Studio Tools for Office23 Adding the Actions Pane Control

24 E Enrichment Chapter: Visual Studio Tools for Office24 Using a ComboBox Object

25 E Enrichment Chapter: Visual Studio Tools for Office25 Calculating Loan Payments with the Pmt Function

26 E Enrichment Chapter: Visual Studio Tools for Office26 Calculating Loan Payments with the Pmt Function

27 E Enrichment Chapter: Visual Studio Tools for Office27 Calculating with the Math Class ►The procedures in the Math class provide you with most of the standard procedures you can use for required computations

28 E Enrichment Chapter: Visual Studio Tools for Office28 Calculating with the Math Class

29 E Enrichment Chapter: Visual Studio Tools for Office29 Program Design

30 E Enrichment Chapter: Visual Studio Tools for Office30 Program Design

31 E Enrichment Chapter: Visual Studio Tools for Office31 Design the Program Processing Objects

32 E Enrichment Chapter: Visual Studio Tools for Office32 Summary ►Use Visual Studio Tools in Microsoft Word ►Create a VSTO Word template ►Add a DateTimePicker object to an application ►Add a table to a Word document

33 E Enrichment Chapter: Visual Studio Tools for Office33 Summary ►Add the Actions Pane Control ►Place a ComboBox object in applications ►Calculate payments using the Pmt Function ►Use Math Class methods in mathematical computations

34 Microsoft Visual Basic 2005 ENRICHMENT CHAPTER Visual Studio Tools for Office


Download ppt "Microsoft Visual Basic 2005 ENRICHMENT CHAPTER Visual Studio Tools for Office."

Similar presentations


Ads by Google