RE: Path for utilities by gordon(dot)bentleymix(at)gmail(dot)com>
gordon(dot)bentleymix(at)gmail(dot)com>
Thu Apr 10 16:55:01 PDT 2008
Bear,
I faced a similar problem with a global add-in that displays a toolbar with
a button that pops a UserForm that shows a list of the company standard
templates and allows the user to select a template and create a new document
from it. In a case similar to what you are facing, the situation was further
complicated by some users being on the network, some not and some running on
Citrix. This meant it was difficult to work out where the templates were
located, as we couldnâ??t just put them in a network share and write code to
look there. Instead, we created an installation package that put the
templates in a standard location within each userâ??s profile. Then I wrote the
following code to populate the list in the UserForm:
Sub ListTemplates
Dim SearchPath as String
Dim MyFolder as String
MyFolder = Options.DefaultFilePath(wdWorkgroupTemplatePath) & "\[standard
location]"
If Dir(MyFolder, vbDirectory) <> "" Then
SearchPath = MyFolder & "\"
Else
SearchPath = Environ("APPDATA") & "\Microsoft\Templates\[standard
location]\"
End If
Call GetTemplates(SearchPath)
End Sub
The GetTemplates subroutine just uses the Dir function to search through the
files in the specified location and, if the file is a template, adds it in
the list in the UserForm.
Note that the line
MyFolder = Options.DefaultFilePath(wdWorkgroupTemplatePath) & "\[standard
location]"
accommodates the Citrix users because we have control over the Citrix
environment and can set the Workgroup templates location. This will also work
if the local network admin puts the templates on a share and sets the
Workgroup templates location on all the machines accordingly.
The point is that itâ??s probably better to use a location that you have more
control over rather than relying on whatâ??s specified under Tools > Options >
File Locations. This method has two clear advantages:
1. You donâ??t have to worry about the users going in and making a change to
something on the â??File Locationsâ?? tab (even if you use something like the
â??Toolsâ?? location that practically nobody ever touches) and thus causing your
code to fail.
2. You donâ??t have to rely in the users to put your components in the right
location.
Of course to make this totally foolproof you would need the services of
somebody familiar with creating installation packages for rolling out your
add-in. However, depending on the number of users and their technical
ability, itâ??s probably worth the effort just to gain an adequate level of
control to ensure your code doesnâ??t fall over. I would also strongly advocate
in favour of using the "APPDATA" environmental variable so each user has
their own copy of the components. Finally, you should be able to adapt the
bit of my code that supports the Citrix users to work with your LAN location,
so you wonâ??t need different versions of your add-in for networked and
non-networked users.
--
Cheers!
The Kiwi Koder
Please note: Uninvited email contact will be marked as SPAM and ignored -
unless you want to hire me. ;-)
"Bear" wrote:
> We've added commands to our Word menus to let the writers open our (HTML)
> style guide and the MW dictionary. I path the style guide to a location on
> our LAN. The dictionary commands are created on installing the MW dictionary,
> but I control the command and toolbar button locations in our menus and
> toolbars.
>
> Now I'm sending my global add-ins to remote offices. The remote writers
> don't have access to our servers (or LAN) and they may have a different
> dictionary installed.
>
> I'm thinking it would be better to code my VBA to use a Word path, like
> those available on Tools > Options > File Locations. Maybe
> Options.DefaultFilePath(wdToolsPath). The users could arrange to put a copy
> of the style guide in that path, and a shortcut or copy of the dictionary EXE
> in that path.
>
> What do you think? Is this a reasonable strategy? Is there a better path to
> use?
>
> Bear
>
> --
> Windows XP, Word 2000