Visio Guy

Visio Discussions => ShapeSheet & Smart Shapes => Topic started by: novski on February 12, 2014, 08:39:11 AM

Title: how to add UserName from Properies to Textfield
Post by: novski on February 12, 2014, 08:39:11 AM
I wanted to add my Username that is stored in the Properties of Visio 2010 to a Field by using Text Fields, Fieldpicture(37), Creator() in a Shapesheet. But this gives out a Document Properties value.
Is it possible to get the Visio Properies Value "Username" stored under File/options somehow?
thanks for hints.
best regards
novski
Title: Re: how to add UserName from Properies to Textfield
Post by: Yacine on February 12, 2014, 09:04:37 PM
Is there really a difference between creator and unsername...?
Title: Re: how to add UserName from Properies to Textfield
Post by: Jumpy on February 13, 2014, 07:36:04 AM
Afaik the creator will always be the name of the one that created the template. Not the one that created a drawing based on that template.
I had problems with that, too. I used VBA in DocumentCreated event to push the name of the current user, that creates the drawing, in a ShapeSheet cell of the document or page.
Title: Re: how to add UserName from Properies to Textfield
Post by: wapperdude on February 13, 2014, 08:08:00 AM
But if you have document properties set to show on 1st save, you can enter the author of the document and then save.  Once saved, I think this name gets retrieved as creator, which is accessed by the insert>field>document info>creator.  (Actually, you can change the File>properties>author at any time and the insert field will update.)  This should overwrite the name of the original template creator.  Seemed to work for me.  V2007.  If you don't set the document properties, then, the author may not inherit the correct name.

HTH
Wapperdude


Title: Re: how to add UserName from Properies to Textfield
Post by: novski on February 13, 2014, 10:18:15 AM
does not work on Visio 2010. Creator stays the Creator of the Template. All trough Microsoft explanes it like it shod. Maybe its a Bug. http://msdn.microsoft.com/en-us/library/office/ms406658%28v=office.12%29.aspx (http://msdn.microsoft.com/en-us/library/office/ms406658%28v=office.12%29.aspx)
Title: Re: how to add UserName from Properies to Textfield
Post by: Jumpy on February 13, 2014, 11:29:34 AM
Just to clarify my  last post. You can manually change the creator and in the document properties and that will be pushed to shapes using the creator() shapesheet function. That's OK. But what I wanted to say is, that the creator doesn't change automatically when you create a drawing based on a template. The creator of the template stays the creator of the drawing unless / until changed manually.

That is different from Word or Excel so I got iritated with that.
Title: Re: how to add UserName from Properies to Textfield
Post by: wapperdude on February 13, 2014, 03:26:03 PM
Being irritated with V2010  :o ...completely understand!!!   8)
Title: Re: how to add UserName from Properies to Textfield
Post by: Yacine on February 13, 2014, 04:58:33 PM
This seems to work (to save in the document's macros of the template):
Private Sub Document_DocumentCreated(ByVal doc As IVDocument)
    doc.Creator = Environ("USERNAME")
End Sub

It will run once, when your user will create a new drawing from the template.
Title: Re: how to add UserName from Properies to Textfield
Post by: novski on February 25, 2014, 10:48:39 AM
much appreciated!
novski