TraceFlags property

Microsoft Visio Developer Reference

TraceFlags property

See also       

Gets or sets events logged during a Microsoft Visio instance.

Version added

5.0

Syntax

intRet = object.TraceFlags
object.TraceFlags = intExpression

intRet

Long. Current trace flags.

object

Required. An expression that returns an Application object.

intExpression

Required Long. New trace flags.

Remarks

The value of the TraceFlags property can be a combination of the following values.

Constant

Value

Description

visTraceEvents

&H1

Event occurrences

visTraceAdvises

&H2

Outgoing advise calls

visTraceAddonInvokes

&H4

Add-on invocations

visTraceCallsToVBA

&H8

VBA invocations

The visTraceEvents flag causes the Immediate window to log most Visio events as they happen. In most cases this occurs even if no external agent is listening or responding to the event. In a few cases, Visio knows there is no listener for an event and does not log those events. Visio also does not log idle events or advises. In addition, some events are specializations of other events and aren't recorded. For example, the SelectionAdded event is manufactured from distinct ShapeAdded events, so the Immediate window records the ShapeAdded events but not the SelectionAdded events.

Here is a string Visio might log when visTraceEvents is selected:

-event: 0x8040 /doc=1 /page=1 /shape=Sheet.1

The number after -event: is the code of the event that occurred. In this case 0x8040 is the code for the ShapeAdded event. The text following the event code differs from event to event.

The visTraceAdvises flag writes a line to the Immediate window just before Visio calls an event handler procedure, and another line just after the event handler returns. This includes event procedures in VBA projects, for example, procedures in ThisDocument. Here is an example of what you might see:

>advise seq=4 event=0x8040 sink=0x40097598
>advise seq=4

These strings indicate the call to and return from an event handler. The sequence number also indicates this event was the fourth one fired by Visio. The code of the event is 0x8040 and the address of the interface Visio called is 0x40097598.

The visTraceAddonInvokes flag records when Visio invokes an EXE or VSL add-on, and when Visio regains control. Here is an example:

>invokeAO: SHOWARGS.EXE
<invokeAO: completed

The visTraceAddonInvokes flag also traces attempts to invoke add-ons that are not present. For example, if a cell's formula is =RunAddon("xxx") and there is no add-on named "xxx", then the message "InvokeAO: Failed to map 'xxx' to known Add-on" is logged.

The visTraceCallToVBA flag writes a line to the Immediate window just before it makes a call to VBA other than a call to an event procedure (use visTraceAdvises to log calls to VBA event procedures), and another line just after VBA returns control to Visio. This flag traces macro invocations, calls to VBA procedures resulting from evaluation of cells that make use of RunAddon or CallThis operands, and calls resulting from selection of custom menu or toolbar items. Here is an example:

>invokeVBA: Module1.MyMacro
<invokeVBA: completed

A message doesn't appear in the Immediate window unless a document with a VBA project is open. Visio queues a small number of messages to log when such a document opens. However, messages are lost if no document with a project is available for lengthy periods. Messages are also lost if VBA resets or if there are undismissed breakpoints.

Code in VBA projects can intersperse their messages with those logged by Visio using standard Debug.Print statements. Code in non-VBA projects can log messages to the VBA Immediate window using Document.VBProject.ExecuteLine("Debug.Print ""somestring""").

The TraceFlags property is recorded in the TraceFlags entry of the Application section of the registry.