A%20Graphics%20Component%20For%20Microsoft%20Office%20Applications:%20%20Programming%20in%20Visio%20-%20Part%201 - PowerPoint PPT Presentation

About This Presentation
Title:

A%20Graphics%20Component%20For%20Microsoft%20Office%20Applications:%20%20Programming%20in%20Visio%20-%20Part%201

Description:

Title: A Graphics Component For Microsoft Office Applications: Programming in Visio - Part 1 Subject: Tech Ed Author: David A. Edson Description – PowerPoint PPT presentation

Number of Views:112
Avg rating:3.0/5.0
Slides: 25
Provided by: Davi1789
Category:

less

Transcript and Presenter's Notes

Title: A%20Graphics%20Component%20For%20Microsoft%20Office%20Applications:%20%20Programming%20in%20Visio%20-%20Part%201


1
A Graphics Component For Microsoft Office
ApplicationsProgramming In Visio Part 1 Mr.
David A. Edson, M.Arch.Technical Product
ManagerDeveloper ToolsMicrosoft
Corporation 4-301
2
(No Transcript)
3
A Graphics Component For Microsoft Office
  • The key is DATA
  • Visio is a means to visualize your datain
    graphical as well as textual form
  • Businesses generate vast amounts of data daily
  • Various functional areas within businesses need
    to share that data
  • Not everyone comprehends data presented in its
    native format
  • A picture is indeed worth a thousand words

4
Data Sharing Enabled Applications
  • Access stores data as records comprised of fields
  • Excel stores data as arrays of inter-related
    cells
  • Word stores data as streams of text with
    embedded graphics
  • PowerPoint stores data as basic images of text
    and pictures
  • Outlook stores data as records of text and field
    related information
  • Visual Basic for Applications is the glue that
    binds these various data sources through
    automation
  • Visio communicates with all of these data sources
    through Visual Basic for Applications and other
    automation controllers

5
Practical Examples
  • Excel data into Visio diagrams
  • Organizational charting
  • Visio data reported to Excel
  • Asset tracking and reporting
  • Word data into Visio diagrams
  • Literary structure
  • Visio data reported to Word
  • Business processes

6
But Before We Begin
  • Remember that the automation/object model is
    actually looking at Visios prime/core technology
    the ShapeSheet interface
  • Automation calls are actually feeding information
    into and pulling information from ShapeSheet
    cells both for SmartShape symbols and the page
    itself

7
How Is The Data Shared?
  • Robust object models are the key to data access
    and sharing
  • Object models are hierarchal structures
  • Each object has properties, methods and events
  • An objects property may be an object further
    down the hierarchy
  • Through object models data is accessed and then
    read by another application

8
Excel - Visio Data Transfer
Excel Application
Visio Application
Object
Object
Workbooks.Item
Documents.Item
Excel Workbooks
Visio Documents
Property gt Excel
Property gt Visio
Object
Object
Workbook Object
Document Object
Workbook.Worksh
Document.Pages
Excel Workbook
Visio Document
eet Property gt
Property gt Pages
Object
Object
Worksheets
Object
Object
Worksheets.Item
Pages.Item
Excel Worksheets
Visio Pages
Property gt
Property gt Page
Object
Object
Worksheet Object
Object
Worksheet.Cell
Page.Shapes
Excel Worksheet
Visio Page Object
Property gt Cell
PropertygtShapes
Object
Object
Object
Shapes.Item
Visio Shapes
Excel Cell Object
PropertygtShape
Object
Object
Shape.Cells
Visio Shape
Cell.Result or
Property gt Cell
Cell.Value
Object
Cell.Formula
Object
9
Traversing Visios Object Model
Obtain a reference to the Application
Object   Public Sub GetAppObject () Dim
appVisio As Visio.Application Set appVisio
GetObject(Visio.Application) End Sub
10
Traversing Visios Object Model
Get a reference to the Documents Collection
Object by calling upon the Documents Property of
the Application Object   Public Sub
GetDocsObject () Dim appVisio As
Visio.Application Dim docsObj As
Visio.Documents Set appVisio
GetObject(Visio.Application) Set docsObj
appVisio.Documents End Sub
11
Traversing Visios Object Model
Obtain a reference to the first document in the
documents collection by calling upon the Item
Property of the Documents Collection
Object   Public Sub GetDocObject () Dim
appVisio As Visio.Application Dim docsObj As
Visio.Documents Dim docObj As Visio.Document
Set appVisio GetObject(Visio.Application)
Set docsObj appVisio.Documents Set docObj
docsObj.Item(1) End Sub
12
Traversing Visios Object Model
Because Visio includes VBA, there is a very
elegant shortcut to reference the currently
active document. Keep in mind that it is not
necessary to obtain a reference to the
Application Object because owing to the fact that
you are working within Visios VBA you already
have an implicit reference to the Application
Object   Public Sub GetDocObject () Dim
docObj As Visio.Document Set docObj
Visio.ActiveDocument End Sub
13
Traversing Visios Object Model
Obtain a reference to the collection of Pages in
the document by calling upon the Pages Property
of the Document Object   Public Sub
GetPagsObject () Dim docObj As Visio.Document
Dim pagsObj As Visio.Pages Set docObj
Visio.ActiveDocument Set pagsObj
docObj.Pages End Sub
14
Traversing Visios Object Model
Get a reference to the first Page in the Pages
Collection by calling upon the Item Property of
the Pages Collection Object   Public Sub
GetPagObject () Dim docObj As Visio.Document
Dim pagsObj As Visio.Pages Dim pagObj As
Visio.Page Set docObj Visio.ActiveDocument
Set pagsObj docObj.Pages Set pagObj
pagsObj.Item(1) End Sub
15
Traversing Visios Object Model
Againthere is a quick method of obtaining a
reference to the currently active Page in a Visio
document through VBA by referencing the
ActivePage Object   Public Sub GetPagObject ()
Dim pagObj As Visio.Page Set pagObj
Visio.ActivePage End Sub
16
Traversing Visios Object Model
Get a reference to the collection of Visio
SmartShape symbols that reside on that page by
calling the Shapes Property of the Page
Object   Public Sub GetShpsObject () Dim
pagObj As Visio.Page Dim shpsObj As
Visio.Shapes Set pagObj Visio.ActivePage
Set shpsObj pagObj.Shapes End Sub
17
Traversing Visios Object Model
Get a reference to the first Visio SmartShape
symbol on that Page by calling upon the Item
Property of the Shapes Collection
Object   Public Sub GetShpObject () Dim
pagObj As Visio.Page Dim shpsObj As
Visio.Shapes Dim shpObj As Visio.Shape Set
pagObj Visio.ActivePage Set shpsObj
pagObj.Shapes Set shpObj shpsObj.Item(1) End
Sub  
18
Traversing Visios Object Model
An alternate to obtaining a SmartShape symbol by
index is calling for it by its name   Public Sub
GetShpObject () Dim pagObj As Visio.Page
Dim shpsObj As Visio.Shapes Dim shpObj As
Visio.Shape Set pagObj Visio.ActivePage
Set shpsObj pagObj.Shapes Set shpObj
shpsObj.Item(Connector.1) End Sub   This
presumes that a SmartShape symbol exists on the
active Page which has the name of Connector.1
19
Traversing Visios Object Model
Yet another alternative is to obtain the
reference to the desired Visio SmartShape Symbol
by locating the currently selected SmartShape
Symbol. To do this we utilize the Selection
Property of the Active Window Object and select
the first Item in the Selection   Public Sub
GetShpObject () Dim windObj As Visio.Window
Dim shpObj As Visio.Shape SetwindObj
Visio.ActiveWindow Set shpObj
windObj.Selection.Item(1) End Sub
20
Traversing Visios Object Model
Now that we have a reference to the SmartShape
symbol in question we can obtain a reference to
the Width Cell. We do this by calling for the
Cells property of the Shape Object   Public Sub
GetCelObject () Dim windObj As Visio.Window
Dim shpObj As Visio.Shape Dim celObj As
Visio.Cell SetwindObj Visio.ActiveWindow
Set shpObj windObj.Selection.Item(1) Set
celObj shpObj.Cells(Width) End Sub Note that
the Cells Property contains a mandatory argument
which is the name of the cell we wish to
reference
21
Traversing Visios Object Model
Finally, with a Cell Object referenced, we can
extract the value in the cell by calling for the
Result Property of the Cell Object, specifying
the units we wish to see the value returned in.
The value will be returned as a double   Public
Sub GetCelValue () Dim windObj As
Visio.Window Dim shpObj As Visio.Shape Dim
celObj As Visio.Cell Dim celVal As Double
SetwindObj Visio.ActiveWindow Set shpObj
windObj.Selection.Item(1) Set celObj
shpObj.Cells(Width) CelVal
celObj.Result(in.) End Sub
22
More Tips, Tricks And Toys
  • Using Visios Database Wizard
  • Using Visios OrgChart Wizard

23
Thank You!Remember your evaluations(what can
make this better?)
  • ContactMr. David A. Edson, M.Arch.Technical
    Product ManagerDeveloper Tools
    MarketingMicrosoft Corporationdavided_at_microsoft
    .com

24
(No Transcript)
Write a Comment
User Comments (0)
About PowerShow.com