Checking template using ShapeSheet in .NET Add-In

A

Amir

I'm trying to check the Created Document's template in a .NET Add-in using
the code bellow:

Private Function IsManagedTemplate( _
ByVal currentDocument As Document) As Boolean

If CBool(currentDocument.DocumentSheet.SectionExists( _
CShort(VisSectionIndices.visSectionUser), 0)) Then
If CBool(currentDocument.DocumentSheet.CellExistsU( _
TEMPLATE_USER_CELL, 0)) Then
Return True
End If
End If
Return False
End Function

that call the function in DocumentCreated's event handler:
IsManagedTemplate(visioApp.ActiveDocument)

visioApp is an object of "Application" Interface in visio PIA and
TEMPLATE_USER_CELL is a constant string with the value of "User.MyT"

also, I made a template that has User-defined part in PageSheet and has one
row in that part named "MyT"

but the function return False.

Any Idea...

Thanks in advance
 
D

David Parker [Visio MVP]

A thought:
If you are trying to detect whether your custom template has been used on
the current document, then suggest you look at the Persistent Events.
The SDK has details.
 
A

Amir

Dear David,

You have answered my questions in last 2 weeks.
I like to say thanks.

about this post, I know about MarkerEvents. But I don't want to use
MarkerEvent.

and a question:
How can I mark DocumentCreated event as a marker one without installing SDK?

Thanks again
 
D

David Parker [Visio MVP]

You only need to install the SDK on your development PC, then use the
PersistentEvents tool to add the events to your template document, before
deploying the template and code to other PCs.
If you create an application event sink then you can listen to the marker
events.
Alternatively, you can use an event sink to listen to every document
created/open event, and then check for the existence of a particular cell.
The SDK also installs Visual Studio Wizards to create Visio COM Addins in
VB.net & C#, addons for C++, plus a publishing tool to modify windows
installation files for Visio.
It is well worth installing the Visio SDK...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top