Volume 2: Solutions and Publishing disclaimer


Macro Recorder considerations



Download 0.72 Mb.
Page12/12
Date10.08.2017
Size0.72 Mb.
#31124
1   ...   4   5   6   7   8   9   10   11   12

Macro Recorder considerations


The macro recorder can be used to record actions taken when using the Visio user interface. These actions are recorded as VBA code. Executing the resulting code should repeat the action.

More generally, the macro recorder is a great tool for learning how the Visio object model works and for putting together small pieces of code that can later be cleaned up and repackaged into useful tools. The final form of the code generated by the recorder may even find itself into code developed in Visual Studio or some other development environment. Although it will necessarily have to be reformatted, that is not usually a big deal.

The important thing is that it makes learning to automate Visio very discoverable – for most things anyway.

Unfortunately there are some areas where the macro recorder for Visio 2007 has limited use. The API programmability model for Themes, Data Graphics, and Pivot diagrams does not cover everything that can be done in the user interface so use of the macro recorder in these areas has been short circuited. This doesn’t mean that you cannot automate these features. It just means you have to learn to do it the old fashioned way, by slogging through the object model, reading, and asking questions, instead of being able to get a nice little code fragment generated for you automatically.


Themes


When the macro recorder is turned on, Edit, Duplicate, and Delete are disabled in the Themes task pane.

Data Graphics


If the Data Graphics task pane is open and the macro recorder is turned on, the task pane is closed.

The Display Data on Shapes menu is disabled and the task pane cannot be reopened until macro recording turned off.


Pivot Diagrams


Pivot diagrams continue to operate when the macro recorder is on, but none of the pivot actions are recorded.

XML changes for Visio 2007


In previously published materials, including the Microsoft Office Visio 2003 SDK, the XML schema for Visio was referred to as "XML for Visio." Starting with Visio 2007, the schema is known as DatadiagramML.

A DatadiagramML file is an XML (Extensible Markup Language) document that contains all the components of a Microsoft Office Visio binary file. Much as you can access a Visio document by using Automation or from the ShapeSheet window, you can use XML and supporting tools to access data in a DatadiagramML file.


Lesson Objectives

After completing this lesson you will be able to:

  • Identify the elements of DatadiagramML that are new for Visio 2007

  • Understand the mechanism that allows for round-tripping Visio 2007 .vdx files to Visio 2003 and back again

  • Understand how custom XML (called SolutionXML) can be stored within a Visio .vdx file

  • Understand how the XML Lite parser is used by Visio 2007



XML Schema Changes

New Elements in DatadiagramML for Visio 2007


Because of new features and functions that have been added to Visio 2007, the following new elements have been added to the XML file format.

  • ADOData

  • AutoLinkComparison

  • DataColumn

  • DataColumns

  • DataConnection

  • DataConnections

  • DataRecordSet

  • DataRecordSets

  • LockFromGroupFormat

  • LockThemeColors

  • LockThemeEffects

  • PrimaryKey

  • RefreshConflict

  • RowMap

  • ShapePlaceStyle

Round tripping DatadiagramML files between Visio 2007 and Visio 2003.


Because Visio 2007 introduces several new ShapeSheet cells and functions the following measures have been taken to ensure that Visio 2007 data can be read by Visio 2003 and not lost when resaved by Visio 2003.
Support of new Visio 2007 ShapeSheet cells in Visio 2003

These new cells do not present a problem for documents saved in binary (.vsd) file format. However, the new XML elements that represent the new cells would not be recognized by Visio in files saved in XML format (.vsx files), because they are not included in the Visio 2003 XML schema. As a resullt, if you attempt to open a Visio 2007 file saved in XML format in Visio 2003, you will get a warning if the XML is trusted (created by Visio); the file will fail to open if the XML is untrusted (created or edited outside Visio).

To address this issue, the elements representing the new cells reference the new "vx:" namespace alias, an alias unrecognized by Visio 2003, and thus considered as unknown XML. The file opens, but Visio ignores the contents of these elements.



...




1

0

...






2

...



Support of new Visio 2007 ShapeSheet functions in Visio 2003

When Visio 2003 loads an XML file created in Visio 2007, it cannot parse new Visio 2007 ShapeSheet functions, and therefore does not recognize any formulas that contain references to new cells or new functions. To address this issue, when you save a Visio 2007 file in VDX format, anytime that a cell contains references to new Visio 2007 formulas and therefore requires that those cells be declared in extended XML format, Visio modifies the file as follows, and as shown in the accompanying example:

  • In the regular XML section, Visio writes the last valid computed value, but not the formula.

  • In the extended XML section, designated by the "x:" namespace, Visio writes both the last valid computed value and the new formula.




4

8.125


...






4

8.125

...




This ensures that Visio 2003 loads VSD and VDX files in the same manner. When it loads the files, Visio writes the extended XML sections as string data stored with an individual shape, as it would any other unknown XML. The last valid computed values are correct, but the formulas specific to Visio 2007 are re-evaluated in the event editing by a user in Visio 2003 forces Visio to recalculate.

In the event you open a Visio 2007 VDX file in Visio 2003, save it as a Visio 2003 VDX file, and then reopen it in Visio 2007, the formulas in the extended XML sections of the VDX file match the original formulas specific to Visio 2007 only if both of the following conditions are met:



  • The last valid computed values in the regular and extended XML sections match each other exactly (indicating that no recalculation has taken place).

  • The current value is a trivial formula (for example, a formula that evaluates to a constant).

Embedding custom XML in a DatadiagramML file


You can include custom XML data specific to your solution within your DatadiagramML file, provided the data contains well-formed XML that complies with the DatadiagramML schema and the internal rules of Microsoft® Office Visio®.

You can embed custom XML in a DatadiagramML file in two ways:



  • As unknown XML, which is XML that Visio does not understand, but will round-trip with a DatadiagramML file when contained in particular elements. This is the means Visio uses to roundtrip documents between Visio 2007 and Visio 2003.

  • As solution XML, which is well-formed XML contained within a SolutionXML element that provides a standardized means of persisting solution data.

At the document level, you can store XML data by using the SolutionXML element contained immediately within the VisioDocument element. You can manipulate the document-level XML data in your solution at run time by using Automation.

At the cell level, you can store well-formed XML data in selected cells by using a string value within a SolutionXML element. When you work with XML data in cells in the ShapeSheet spreadsheet or by using Automation, you can retrieve your XML data as you would any string value in a cell.



XMLLite


Visio 2007 uses XMLLite to read and write Visio xml files. XMLLite is a light weight (very small and it has no dependencies) .dll that is designed for performance. However, to achieve great performance, XMLLite is also “lite” on validation.

Generally, XML usage scenarios can be generally divided into two categories:



  • Some scenarios work with XML documents that come from external sources, and it is not known whether the XML documents are valid. In these scenarios, verification of validity is important. Typically, developers use XSD schemas or Document Type Definitions (DTDs) to verify validity. Performance may be a concern, but the overriding concern is that the application reading the XML receives a valid document. Saving and loading documents from and to a variety of applications is a usage scenario that falls in this category.

  • Some software systems use XML as a data store or a means for communication. In these scenarios, the developer knows that the XML document is valid, perhaps because another part of the system (which is under the control of the same developer or organization) generated the XML. The question of document validity is not an overriding concern. One example of this approach is where the software system runs on a server farm, and XML is used to communicate between various servers and processes. Another example might be one where a relatively complicated application has to store and retrieve a large amount of information. The developer completely controls the format of the XML document.

The focus of XmlLite is on performance. Therefore, XmlLite is most appropriate in the second of the two scenarios. XmlLite enables developers to write efficient (fast) code to read and write XML documents. In most scenarios, XmlLite parses faster than either the DOM in MSXML or SAX2 in MSXML. Reading and writing Visio XML and SolutionXML is like the second of the two scenarios, where the potential risk for bad XML is low. In Visio 2007 the XML parser validates any XML written during the Save operation.

XMLLite is included in Vista, but must be downloaded for Windows XP and Windows Server 2003. When Visio is first launched on a Windows XP(SP2) or Windows Server 2003 platform, Visio will prompt for the user to go to the Windows download page and download/install the XMLLite component, if it is not installed.  The side effect of not doing so will be poorer performance in XML operations.



Additional Resources

MSDN Office Developer Center - Visio 2010

All things related to developing with Visio. As new material becomes available, it should be posted here.

http://msdn.microsoft.com/en-us/library/ee839657(office.14).aspx


Designing Shapes for use with Themes in Visio 2007

Learn about the new Theme feature in Microsoft Office Visio 2007, how it works, and how it affects and improves your ability to design shapes.

http://msdn2.microsoft.com/en-us/library/aa445858.aspx



Trust Center and Security Settings

About Security Settings and Running Code in Visio

http://msdn2.microsoft.com/en-us/library/aa342055.aspx

Security Notes for Microsoft Office Solution Developers

http://msdn2.microsoft.com/en-us/library/aa433259.aspx

Create, remove, or change a trusted location for your files

A trusted location is typically a folder on your hard disk or a network share. Any file that you put in a trusted location can be opened without being checked by the Trust Center security feature. This article explains why trusted locations can be useful and how you create them. It also outlines precautions that you should take before using a trusted location.

http://office.microsoft.com/en-us/visio/HA100319991033.aspx



Overview of security in the 2007 Office system

An organization's financial success often hinges on the productivity of its information workers and the integrity and confidentiality of its intellectual property. In the past, satisfying these business needs was difficult for IT professionals because protection often came at the expense of productivity. With a redesigned security model and many new and enhanced security features, the 2007 Microsoft Office system makes it possible for IT professionals to design desktop configurations that mitigate security threats while maintaining information worker productivity.

http://technet2.microsoft.com/Office/en-us/library/67869078-71c6-45f5-aab0-0823c83aed541033.mspx



Configure trusted locations and trusted publishers settings in the 2007 Office system

http://technet2.microsoft.com/Office/en-us/library/05c24b5c-122c-42f2-a4a5-1f09a066558f1033.mspx?mfr=true

Configure security settings for ActiveX controls, add-ins, and macros in the 2007 Office system

http://technet2.microsoft.com/Office/en-us/library/5b5835c3-8c7d-429a-b5b1-e3dd1fa9534b1033.mspx

Specific Security Considerations for Office Solutions

The security features provided by the Microsoft .NET Framework, Microsoft Office 2003, and the 2007 Microsoft Office system can help to protect against a variety of possible security threats in Visual Studio Tools for Office solutions. This topic provides recommendations to help you protect your Visual Studio Tools for Office solutions against possible threats, and also includes information about the behavior of Microsoft Office security settings on Visual Studio Tools for Office solutions.

http://msdn2.microsoft.com/en-us/library/1thd35d7(vs.80).aspx



XML for Visio

Overview of DatadiagramML

Visio XML reference.

http://msdn2.microsoft.com/en-us/library/aa721904.aspx



Round-Tripping DatadiagramML Files

Covers information on what happens to XML data when round tripping Visio files between Visio 2003 and Visio 2007.

http://msdn2.microsoft.com/en-us/library/aa721905.aspx



New Elements in DatadiagramML in Microsoft Office Visio 2007

http://msdn2.microsoft.com/en-us/library/aa721903.aspx

Embedding Custom XML in a DatadiagramML File

You can include custom XML data specific to your solution within your DatadiagramML file, provided the data contains well-formed XML that complies with the DatadiagramML schema and the internal rules of Microsoft® Office Visio®.

http://msdn2.microsoft.com/en-us/library/aa721898.aspx



XML Lite

This documentation provides information about XmlLite, Microsoft's new XML parser.

http://msdn2.microsoft.com/en-us/library/ms752872.aspx



All downloads for XML Lite

http://www.microsoft.com/downloads/results.aspx?pocId=&freetext=xmllite&DisplayLang=en

XMLLite for Windows XP (KB915865)

Download for XML Lite for Windows XP

http://www.microsoft.com/downloads/details.aspx?FamilyID=d7b5dc81-ad14-4de2-8ad5-8c4a9aab5992&DisplayLang=en



Developer Features Review

Questions


  1. There is no Theme object in the Visio object model. How are these stored?

  2. How do Color Schemes still work in Visio 2007?

  3. Where does the developer find the information for the currently applied theme?

  4. If a shape has a theme applied, but then is protected against further applications of a theme, how does the developer know which theme the shape gets its theme features from.

  5. Custom solutions may require the storing of data along with the
    Visio drawing. What mechanism is provide to store this data in XML form?

  6. What namespace is used in the Visio .vdx file when capturing cell values that are new to Visio 2007?



Answers


  1. New or duplicated Themes are stored as Masters. The built-in themes are not in the object model.

  2. The Color Scheme add-on “CS” still exists. If a drawing was created in an earlier version of Visio using Color Schemes, that drawing has an Action cell that calls the “CS” add-on.

  3. In the page’s ShapeSheet in User.msvThemeColor and User.msvThemeEffect.

  4. The shape has user defined cells User.msvThemeColor and User.msvThemeEffect which may be different from those on the page’s ShapeSheet. Once the shape is protected against themes, these cells do not change.

  5. SolutionXML

  6. The vx namespace.




Microsoft Visio 2010 Developer Training © 2010 Microsoft Corporation. All rights reserved.

Volume 2: Solutions and Publishing






Download 0.72 Mb.

Share with your friends:
1   ...   4   5   6   7   8   9   10   11   12




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

    Main page