Volume 3: Programming with the Visio Object Model disclaimer

Download 0.78 Mb.
Size0.78 Mb.
  1   2   3   4   5   6   7   8   9   ...   36


Microsoft Visio 2010 Developer Training
Volume 3: Programming with the Visio Object Model

© 2010 Microsoft Corporation. All rights reserved.

Microsoft®, Internet Explorer, and Windows® are either registered trademarks or trademarks of Microsoft Corporation in the United States and/or other countries.

The names of actual companies and products mentioned herein may be the trademarks of their respective owners.

The contents of this package are for informational and training purposes only and are provided "as is" without warranty of any kind, whether express or implied, including but not limited to the implied warranties of merchantability, fitness for a particular purpose, and non-infringement.

No part of the text or software included in this training package may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or any information storage and retrieval system, without permission from Microsoft®. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information presented after the date of publication. The names of actual companies and products mentioned herein may be the trademarks of their respective owners.

To obtain authorization for uses other than those specified above, please visit the Microsoft Copyright Permissions Web page at http://www.microsoft.com/about/legal/permissions

This content is proprietary and confidential, and is intended only for users described in the content provided in this document. This content and information is provided to you under a Non-Disclosure Agreement and cannot be distributed. Copying, disclosing all or any portion of the content and/or information included in this document is strictly prohibited.

Table of Contents

VBA Primer 4

Event Driven vs. Procedure Based Programming 5

Visual Basic Editor 7

Variables 10

Dimensioning 12

Data Types 14

1.Using Hungarian Notation 16

Manipulating Variables 18

Exercise 1 20

Other Operations 22

Exercise 2 24

Data type conversions and variable scope 27

Exercise3 29

Constants 31

Control structures 32

2.Branching Statements 32

3.Looping Statements 34

4.Jumping Statements 36

5.Procedures 37

6.Functions 37

VBA Primer Conclusion 40

Introduction to Automation 41

Introduction 43

Automation Basics 44

Programming a Server's Objects 46

VBE Tools Menu 48

Object Browser 50

Review: Introduction to Automation 51

1.Define Automation. 51

2.What actually happens when one program uses Automation to drive another program? 51

3.What allows Visio to be a controller and a server at the same time? 51

4.What function does a digital signature provide? 51

1.Automation allows one program to incorporate the functionality of another by using objects exposed by the other program. 51

2.The server application returns a handle to an object. The controller application can use this handle to ask the server application to do things with this object. 51

3.Because Visio has embedded VBA it can be used as a controller. Because it exposes its object model it can be used as a server. 51

4.Using digital certificates, a developer can digitally sign a project and be identified as a trusted source. 51

Automation and Visio Technology 53

Overview 54

The Visio Object Model 55

A Sample Visio Program 58

Getting and Setting Properties 60

Invoking Methods 62

Compound References 63

Lab 3.1: Get the Name of an Open Visio Document 64

Coding Issues 65

Running Your Program 67

RUNADDON(“string”) 70


Where to Find Visio Automation Information 73

Lab 3.2: Running VB Add-ons 75

Review: Automation and Visio 77

Generating Drawings 79

Creating a Document 80

Getting a Reference to the Master 82

Dropping the Master on the Page 84

Adding Text to Shapes 86

Getting Formulas of Shapes and Pages 87

Getting a Formula or Its Result 90

Setting a Formula 93

Tips for Positioning Shapes 95

Tips for Positioning Shapes (Continued) 96

Connecting Shapes 98

Getting the Cell to Glue 99

Gluing to the Other Shape 100

AutoConnect Mode 102

Adding Data to Shapes 106

Adding Sections and Rows 107

Lab 3.3: "Hello World" 109

Review: Generating Visio Drawings 110

Getting Data From Drawings 111

Overview 112

Iterating Through a Collection 113

Getting Data from Documents 115

Noteworthy Document Properties 116

Getting Data from Pages 118

Getting Data from Shapes 119

Getting Data About Connections 121

Connect Object for a Control Handle to a Shape 123

Connect Object for a 1-D Between 2-D Shapes 124

More Connectivity API options 126

Getting a Selection Object 133

Working with Windows and Selected Shapes 135

Getting Cells with CellsSRC 137

Determining Shape Proximity 139

SpatialRelation 140

Lab 3.4: Calculate the Area of a Shape 141

Review: Getting Data from Drawings 142

Managing Events 144

Learning Objective 145

Introduction 146

Cell Dependencies 147

Force Dependencies with DependsOn 149

DependsOn Example 150

SetAtRef ShapeSheet Function 153

Use the ShapeSheet to Manage Events 155

Use Formulas Over Code 156

Visual Basic for Applications Code Behind Events 157

Supported Events 158

Hierarchical Event Sets 159

Built-In Document Events 160

WithEvents Keyword 162

Controls 164

Query Events 166

Query Events (Continued) 168

Marker Events 170

Scoping Methods 172

Lab 3.5: Create a Shape Area Calculator 174

13.Points to Consider 174

Other Considerations 175

Review: Managing Events 177

Automating Data Graphics 178

Lesson 1: Data Graphics Concepts 180

14.Overview of Objects / Methods / Properties 180

15.Creating Data Graphics Masters 183

16.Creating Data Graphics Items 187

17.Managing Data Graphic Masters 211

Lesson 2: Related Topics 215

18.Shape Data Management 215

Lab 3.6: Data Graphics 220

19.Exercise : Create a Pie Chart data graphic item 220

20.Exercise 2: Test the New Pie Chart data graphic item 223

21.Exercise 3: Add a data bar to the Data Graphic that totals the 9th, 10th, 11th, and 12th grade slots for a class section. 224

Additional Resources – Data Graphics 226

Review: Automating Data Graphics 228

Managing External Data Sets 231

Lesson 1: Data Link Concepts 232

22.Overview of Objects / Methods / Properties 232

23.Data Sources 237

Lesson 2: Managing Data sets 248

24.Linking data to shapes 249

25.Managing Refresh 255

26.Changing data locations 262

Lab 3.7: Data Linking 264

27.Exercise : Connect to an external data set 265

28.Exercise 2: Link the Instructor shapes to rows in the Teacher DataRecordset 265

29.Exercise 3: Drop and link the Section shapes to the rows in the Section DataRecordset 266

30.Exercise 4: Change the external data, refresh the drawing, and manage changes required by the data 266

Additional Resources – External Data 267

Review: Managing External Data Sets 269

Visio Software Development Kit (SDK) 271

Lesson 1: Setup / Overview 273

31.Software Requirements for Visio 2010 SDK Tools and Samples 274

32.Documentation 275

33.Containers 276

34.TypeLibs Included 281

35.Changes from Visio 2010 SDK 281

36.Visual Studio 2005 and 2008 Add-in Wizards 282

Lesson 2: Tools 290

37.Event Monitor 290

38.Demo: Use Event Monitor to track actions in Visio 292

39.About Using the Persistent Events Tool 293

40.Print ShapeSheet 298

41.Publish Component 300

Lab 3.8: Build and run the Visio SDK Flowchart sample 308

42.Exercise : Build and run the Flowchart (VB.NET) sample code from the SDK 308

43.Exercise 2: Code review. 310

Additional Resources - SDK 312

Review: SDK 313

Visio Drawing Control 315

Lesson 1: Concepts 316

44.Requirements / Containers 316

45.Demo: Drawing Control 318

Lesson 2: Creating an application 329

46.Best Practices 329

47.Porting existing code 330

48.The Controls SDI (single document interface) 331

49.Getting a reference to the Visio Application Object 333

50.Loading a document 333

51.Saving a document 335

52.Integrating the control with the host container 337

53.Page sizing and zoom 338

54.Window management 340

55.Integrating menus and toolbars 340

56.Handling events 341

57.Using the Visio Control with the Internet Explorer Browser Control 344

Lab 3.8: Using the Visio Drawing Control 345

58.Exercise : Set the Src property of the document and display the External Data window 345

59.Exercise 2: Add menus to place and delete Sections 346

60.Exercise 3: Add SaveAs menu 347

Additional Resources – Drawing Control 348

Review – Visio Drawing Control 350

Adding the Office Fluent UI to an existing Add-in 353

61.Getting started 353

62.Updating References 354

63.Preparing the add-in for Ribbon support 354

64.Creating the Ribbon 357

65.Callbacks 361

66.Manage Ribbon control state 362

67.CommandBars and Ribbon 367

68.Sample Code 367

Download 0.78 Mb.

Share with your friends:
  1   2   3   4   5   6   7   8   9   ...   36

The database is protected by copyright ©ininet.org 2024
send message

    Main page