Link to home
Start Free TrialLog in
Avatar of Roger
RogerFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Shape.comments collection and Application.UserName in Visio 2013

I seek to colour individual shapes according to whether they contain comments from me, from a user of a different computer, or both.
The shp.comments collection allows me to access commenters' names, texts etc, and I'm feeling my way in..

For i = 1 To shps.Count    '[shapes collection
            Set shp = shps.Item(i)
            Set cmnts = shp.Comments  '[comments collection
        For x = 1 To cmnts.Count
                Set cmnt = cmnts.Item(x)
                Debug.Print "i = "; i & "; x = "; x & "; shp.ID = "; shp.ID & "; cmnt.text = "; cmnt.Text & "; cmnt.AuthorName = "; cmnt.AuthorName
        Next x
    Next i

I think cmnt.AuthorName = visio.application.UserName; is that correct?

I EXPECT that when a visio file is passed between two commenters, who comment on the SAME shape, those commenter's different Application.usernames will appear in the same Cmnt collection: both their comments and their UserNames.
IS this correct?  And if they have same UserNames, would the same name appear above their respective comments?

I cannot simulate different UserNames on one single PC, since cmnt.authorname, is a read-only property.
MSDN reads: visio.application.UserName is read/write (https://msdn.microsoft.com/en-us/library/office/ff765795.aspx),
I tried to change the User.Name of my visio application ..
    Application.UserName = "NewName"
    MsgBox "Application.UserName"
    No bug came up, but no change of name was effected.

IS there a way of changing Application.UserName in visio when the program is running?

Thanks
Kelvin
Avatar of Rgonzo1971
Rgonzo1971

Hi,

have you tried

Application.UserName = "NewName"
MsgBox Application.UserName

Open in new window

Regards
Avatar of Roger

ASKER

Rgonzo:
Apologies: I should have typed:
    Application.UserName = "NewName"
    MsgBox "Application.UserName = " & Application.UserName

And the result was the msgBox reported my own name, not "NewName"

Kelvin
ASKER CERTIFIED SOLUTION
Avatar of Rgonzo1971
Rgonzo1971

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Roger

ASKER

Rgonzo:
You set me on the right track. It lead to the ability to switch the UserName exhibited in a Visio comment.

As you said, the key step is to go to  Visio Options/General/'Personalise your copy  of Microsoft Office'.
There is a box for User Name (referred to below). And a box below that  for 'Initials'
Beneath 'Initials' there is a critical CHECK BOX: 'Always use these values regardless of sign in the Office'

It you DONT check this check box you will NEVER change the User Name (above) even if you change Application.UserName = "another name"
But:
If you check this box then:
(a) any change via Application.UserName = "yet another name" appears in the UserName box (above) and is transmitted to the author name in visio.shp.comments
(b) If you have previously run Application.UserName = "yet another name2" with the check box UNCHECKED then if you later check that box, the new name appears immediately in the UserName box (Above) and appears in the Author name of shp.comments.

So by these steps I can simulate 2 different users from the same PC!

After all this instant excitement, I need to test these statements in the cold morning light again, before making a final confirmatory report and awarding you max points! Is that ok?
PS: Thanks!!
Avatar of Roger

ASKER

Rgonzo:
Thanks.
I confirm my notes above, and add that with the Visio options checkbox 'checked' and a new username in the Visio name box, then if you open excel or powerpoint, they will also display the same new userName.

Then, if you then unclick the check box in the Visio option panel, then (open) excel or powerpoint files will revert to their original Application. username (provide perhaps that you change tab away from the file tab and then back to the File tab, to force the option panel to update.

Bottom line: The checkbox determines whether a change of Application.userName is actually displayed within the visio file. Working the checkbox is a great way to simulate the activities of two dfferent users as they alternately write comments on the same Visio file. Be cautious in using it for any other purpose.

Thanks for helping me toward the root of the problem

Kelvin