Stencil file in multi-user environment

Started by visio(nary), May 06, 2014, 12:33:19 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

visio(nary)

Hi to everybody,

I "exported" my generic VBA-code into an external stencil file to allow a much
easier update process if required. Everything worked great (the stencil file
is located on an external network drive) until more users tried to open a
visio document that references the "global library".

To update older visio files too, I did a coded a little tool that updates
the file an sets the reference to my new library.


' -----------------------------------------------------------------------------------
' btnStartUpdate_Click
' -----------------------------------------------------------------------------------
Private Sub btnStartUpdate_Click()
    Call OpenVisioDocument
End Sub

' -----------------------------------------------------------------------------------
' OpenVisioDocument
' -----------------------------------------------------------------------------------
Private Sub OpenVisioDocument()
    Dim strFile As String
    Dim strReference As String
    Dim strCode As String
   
    Dim blnRefAlreadySet As Boolean
   
    Dim intI As Integer
   
    Dim vsoWindow As Visio.Window
   
    Dim vbComp As VBComponent
    Dim vbRef As Reference
   

    strFile = modFileIO.GetFilename() ' external function

    Application.Documents.Open strFile
       
    ' --- path to stencil file
    strReference = "\\xxxxxx\VBATemplate.vss"
   
    ' --- add reference
    blnRefAlreadySet = False
    For Each vbRef In Application.ActiveDocument.VBProject.References
        If LCase(vbRef.FullPath) = LCase(strReference) Then _
            blnRefAlreadySet = True
    Next vbRef
    If Not (blnRefAlreadySet) Then _
        Set vbRef = Application.ActiveDocument.VBProject.References.AddFromFile(strReference)
       
    Application.ActiveDocument.Save
    Application.ActiveDocument.Close
       
    Call CloseVBA
   
End Sub

' -----------------------------------------------------------------------------------
' CloseVBA
' -----------------------------------------------------------------------------------
Private Sub CloseVBA()

    'Application.EventsEnabled = False
    VBA.SendKeys "%{F11}%q"
    'Application.EventsEnabled = True

End Sub


The code mentioned above does NOT work if another user has opened a file that references the
same VBATemplate.css too. It seems that there's a problem if the file is already opened?!

Is there any chance to gain multi user access on the same stencil file?

Thanks in advance!
visio(nary)

Jumpy

I ran into the same problem some time ago. Seems you can't "share" the code project of a stencil.
(Although you can "share" the stencil and shapes on it without problems)

My workarround:
I created a stencil without shapes, that only contains my VBA Code.
In each of my Templates/Drawings I reference that Code-Stencil (only the name) in the VBA-Editor-Librarys.
In my network drive I have a folder "stencils" that contains all my normal custom made stencils and
I have a folder "code". I that folder I have a subfolder for each user named after the windows username.
In each users Visio, in the options, I entered the path for the custom stencils and for the code-stencil for that user, sth. like:
"T:\MyNetworkPath\Visio\CustomStencils;T:\MyNetworkPath\Visio\Code\Username"

If I have some changes in my code, I have to copy the code stencil for every user.

visio(nary)

Hi Jumpy,

many thanks for your reply!
I also have a stencil file that only contains VBA code and no stencils.
In that case (as you mentioned) I could also place the stencil file directly in a local folder such as "C:\Visio Templates\VBATemplate.vss".
The update process would cost the same effort except that the new version of the file would have to be distributed via E-Mail for instance.
What if a new user wants to use your "template" in your scenario? Create a new "working directory" for every new user?
To be honest, I dont like that workflow ;)

What if I open the file hidden in the back rather that create a reference? Would it then be possible to reference modules inside that file?

Thanks in advance!
visio(nary)

visio(nary)

By the way, how do you add a reference to only the name of the stencil and not to the whole path?

Thanks!
visio(nary)

Jumpy

#4
I'm currently not at the office and will try to answer your question "How I did it" this evening (if it's not to late) or tomorrow morning, when I'm back in the office.

Quote
What if a new user wants to use your "template" in your scenario? Create a new "working directory" for every new user?
To be honest, I dont like that workflow ;)
That's our workflow for a new user:
- Cretae a subfolder on the network folder with the stencils with his username.
- Copy the code.vss to that folder.
- Installing Visio on his machine.
- Change the pathes to stencils and template in the options of his Visio.
- Create a desktop-shortcut to Visio with startup parameters so Visio always starts with a certain drawing
(as it is impossible to start Visio with a certain template I start it with a certain drawing, that only contains a Logo (thus simulating a splash screen) and some VBA code (that is the main reason for that drawing)  that loads a certain template.

As we only have 5 uses and users change perhaps one a year it's not much effort.

After changes in the Code.vss I use a VBA macro to distribute the code.vss from my network folder (witch contains the master or root stencil). It's an rather easy macro, and less complicated that distributing stencil files via email. Only drawback: I have to distribute the code.vss after every user closes Visio. But that is normaly no problem.

visio(nary)

Hi Jumpy,

many thanks for your reply!
The workflow seems nice for a manageable amount of users.

I did a version checker that checks a history file on the network drive and compares the version number with the locally installed version.
It works fine except it is NOT possible to directly overwrite the outdated version with the newer one from the network.
As you told already the users have to quit the application since the stencil file is running in the back. Therefore it is impossible to overwrite
the file while it is opened already..... Mmmmmhhhhhhhh - Wasted hours of programming - I should have mentioned that scenario right from the beginning -> damn....

I would like to open a command line and start a xcopy for instance to update the files in the back automatically...
No - sorry - same problem here - the file is write protected - even for an external app I think...

Any change to initiate the update process after the document is closed?

Many thanks!
visio(nary)

visio(nary)

Good morning to everybody (it's 07:35 a.m. in my time-zome)  8)

After a few days of trial and error I have decided to just inform the user about availiable updates through a background version checker, which
is fired every time a new drawing is opened in combination with a user form. The form tells the user that he has to quit his instance of Visio in
order to copy the new file version from the network drive into his local directory.

It works great, so I think the thread could be closed...

Have a nice day and many thanks for your support!
visio(nary)

Jumpy

Oh, I forgot this thread. I'm still owing you an answer:

Quote
By the way, how do you add a reference to only the name of the stencil and not to the whole path?

I don't. I actually add the complete path which is sth. like:

T:\Networkdrivepath\Visio\Code\RS\Code.vss

Where RS is my Windows Username.

The Visio of other users can't see that path because it is not entered in the pathes section of the options. But Visio is intelligent enough to look elsewhere for Code.vss and finds it in the path that is entered in that Visio user pathes section.