PDA

View Full Version : Template Menu / Toolbar



chezt
02-18-2007, 02:18 AM
Hey there,

Novice and new-by on board. Yes I'm sure you're cringing as you read this but I would love some help and at the least a point in the right direction. First off I have dabbled a bit in excel vba but am now looking at a little project in word vba for work.

Scenario:
We have company templates which we have on a network and ideally what I would like is to have an add-in or something which creates a toolbar or menu which lists the templates in the user and workgroup file locations. If there are any subfolder in the these directory it would create a submenu and further list the templates in these folders.

I have looked on the net and while I've come across a few solutions it doesn't explain how to do it very well or is not flexible enough for what I'd "ideally" like to have.

I have a little idea of how I might like to do it but am totally lacking the info experience. Ideally I would like the menu to be flexible enough to change when any changes were made with the files themselves. i.e. if I added a template the next time I opened a word document it would be listed.

Again would appreciate any help although I relaise you're having to help a million people. Even an algorithm of some sort which I could research to figure out how to do it would be much appreciate.

Grateful for your patience.

chezt
a keen beginner (well sort of a beginner ...not totally)

mdmackillop
02-18-2007, 05:27 AM
Hi Chetz,
Welcome to VBAX
The simplest approach I can suggest is a Userform with a series of listboxes to list the templates in each location and its sub-folders. Listboxes for sub-folders would be added automatically. How many sub-folders are you likely to have?
The attachment is partially complete; Workgroup folders would be added in similar fashion. Constants and array sizes need to be set to suit.
Regards
MD

mdmackillop
02-18-2007, 06:20 AM
It should look like this.

fumei
02-18-2007, 04:16 PM
Hey Malcolm. How do you get those attached images?

mdmackillop
02-18-2007, 04:37 PM
Hi Gerry,
Alt+Print Screen into Paint. Save as JPG and post as attachment.

fumei
02-18-2007, 04:41 PM
You mean any JPG sent as an attachment is not maintained as a file, but is inserted as an image? I never knew that.

mdmackillop
02-18-2007, 04:48 PM
That's it. I had to ask how to do it as well (once upon a time)

chezt
02-20-2007, 03:11 AM
Thank you.

It's not what I had in mind but having said that it's probably a better solution. Will study the code and learn how it works etc. and see how I go. Thank you heaps.

First time I've joined a forum so am still learning the ropes :-).

What would we do without you :clap::bow: hee hee.

fumei
02-20-2007, 12:35 PM
chezt - to use a template you go File > New.

File > New > general templates will display a dialog with all templates in both User Templates, and Workgroup Templates. So I am not sure why you do not simply use this.

We have company templates which we have on a network and ideally what I would like is to have an add-in or something which creates a toolbar or menu which lists the templates in the user and workgroup file locations. File > New does this. Any subfolders off the User Templates folder show as Tabs. Click the tab and you can see those templates.

chezt
02-21-2007, 02:54 AM
LOL...you must think I'm some kind of lemon...If I didn't know how to do that I probably shouldn't know what VBA is...hee hee.

Sorry.. thank you for you input about the templates. I realise it seems stupid but what I'm trying to do is make things easier my computer-challenged colleagues at work. Harsh I know but I'm having to email templates to staff because they don't know how to do exactly that...File, new...huge learning curve..

Anyhow....what I'm trying to do is have an add-in which creates a "Template" menu in the normal toolbar i.e. you have the following Menus:
File, Edit....Templates
In the templates menu I want it to automatically list the names of templates in the user and workgroup folders which is set in the Tools, options, file location. If there is a subfolder in the directory I want it to create a submenu under templates...there is a solution to this however it is pretty static in that it is not flexible enough. You record macros for opening each individual templates, create a toolbar and menu and then assign the macros to the menu. That's fine however I want it to be more dynamic in that the Templates menu changes with the contents in the folders.

I was thinking along the lines of checking the default file directories for the work and user group folders, get the names of the files and folders and use it as the list for the menu,etc. I kind of have an idea but haven't quite got the steps...a little difficult as I still haven't got a thorough knowlegdge of the different things I need to call, manipulate etc.

That's my story. I've looked everywhere to find a solution and am trying to figure it out myself. Once I get an idea in my head I can't stop till I've solved it...

So end result - it takes one click to get to the templates; no navigation just click and choose;

I hope I seem less of an idiot now :-)

fumei
02-21-2007, 02:59 PM
Sorry...but, huh?

Are you saying user are NOT doing File > New to use templates?

How are they using them then?

chezt
02-24-2007, 01:56 PM
They're not :-). They're emailing me for the templates! I've created the templates with instructions on how to use it, File, New etc. but they don't do it.

I've seen a local company here in NZ with modifications in word. They have the template menu thing instead of having to do the File New. I realise all it is , is 3 to 4 clicks to use templates using the File, New way but the menu I'm talking about takes only 2 clicks, it's right there as part of the menu and as dumb as it sounds, for a lot of people it would just simply be nicer.
Will post back here with a draft solution when I get it so you can understand what I mean.

Bilby
02-25-2007, 01:53 PM
Greetings,

I don't know if this will help but I have an app that presents the user with a listbox containing descriptions of documents. When the user selects one the app then creates the document without the user needing to know where the template is or how to create a doc from it. This allows our users to concentrate on what they do best(write content).

As an overview it works like this. The userform has a Listbox, this box is filled by an array (strDescription) and the user selects a description of the needed document. There is a second matching array (strTemplate) which contains the path of the template as in example below;

strDescription(5) = "This template makes a Invoice"
strTemplate(5) = "The template.dot"

When the user selects the document the app locates the template by using the listboxes ListIndex item

strDocName = strTemplate(Me.ListBox1.ListIndex + 1)

then its simply a matter of using Documents.Add to create the document.
You can use INI files to store the path to the templates, where the user will save the finished documents etc. The important thing is to sit down with a piece of paper and map out exactly what you need to do, this type of app can quickly get out of hand.

fumei
02-26-2007, 07:39 AM
The important thing is to sit down with a piece of paper and map out exactly what you need to do

THIS is for sure. It is the most commonly NOT done thing.

Yes, if you are using INI files, you can certainly do what you are talking about.

TrippyTom
02-26-2007, 11:08 AM
Personally (and this will probably label me as an old curmudgeon) I think the user just has to suck it up and get used to technology. Writing all that code to save 2 mouse clicks is pointless.

[edit] not pointless. There is value in learning how it would be done, but i just don't see the return for all that work being worth it.

fumei
02-26-2007, 12:12 PM
As a professional trainer...I would have to agree with you. I was (I know many would not believe this) trying to be polite.


So end result - it takes one click to get to the templates; no navigation just click and chooseSort of. If there are sub-folders there is still navigation.

mdmackillop
02-26-2007, 01:06 PM
Hi Gerry,
No dispute with the File/New process, but I quite like Bilby's descriptive approach. To combine this with with my userform approach, rather than use a text file, I can store text in the Document Properties. Can these be accessed without opening the file? My attempts so far are unsuccessful.

fumei
02-26-2007, 06:38 PM
The immediate top of my head answer was no, you can't. HOWEVER, I seem to recall this has come up previously and someone found a way to get at Document Properties (Word properties, not file properties) without opening the file. Or maybe I have become senile and just think that happened.

I will try and search....

fumei
02-26-2007, 06:44 PM
I would like to point out that in terms of efficiency a text file would probably be better.

1. ONE location for the data.
2. There is potentially a bunch of text. The description, and the path for each template file.

Document Properties is not the best place for this, but...shrug...maybe.

Bilby
02-27-2007, 02:12 PM
Its called dsofile, its utterly brilliant. I have a utility that allows me to point at a users directory and compare the doc properties of their templates with my authorised ones. dsofile is limited in what it can do but what it does is excellent!

As for TrippyToms comment about users needing to suck it in, well thats partially right. Some users just don't make much effort, but most of my users interact with a document management system and to make matters worse they're writing complex technical documents. The less they need to worry about the mechanics of publication and the formatting rules the better.

Besides if they knew how to use Word then I'd be out of a job:rotlaugh:

On a different note, I also write a user specific INI file to the users profile directory to store user specific options/data. I know that the registry is allegedly the ultimate repository but I LOVE my INI files!

mdmackillop
02-27-2007, 02:47 PM
Thanks Bilby.
I know I've seen this before. cpearson has a good article on it.