PDA

View Full Version : Best practise when to build up templates?



GrodanBoll
03-22-2005, 01:09 AM
Hi :)

For some time ago I have built up my companies templates with help of VBA and userforms. I'd also put the common code in a stand alone template for the other tamplates to access.
But I think that it is to time comsuming to update the templates or to create new ones.

I then started to think of a better way to make templates.
Maybe I could only use a userform tp populate the bookmarks in the header and footer, and for the other required field user protected sections with formfields.
Or, maybe use hidden tables with reqired form fields in protected sections to populate all of the bookmarks?

How do you pros build up your template projects?
Is there a best practise?

Any ideas would be greately appreciated. :banghead:

Thanks
Grodan

Steiner
03-22-2005, 01:40 AM
Currentyl I use a combination of both:
I have a global template with functions, fixed dialogs (address etc.), customizable dialogs (for editing an array of data in a list) and a custom built search & replace that looks for specific text I use in templates and replaces that as needed (eg. access data stored to the selected address, company / user information).

Then I decide: more complex templates get their own
userform, basic ones just fields and text.

The reason I still use userforms is just, that I have a lot more control. I can store data somewhere else to access it from other documents, I can integrate constraints on the data entered and I can guide the user by displaying only dialogs that are needed in a current situation.
Some (if not all) of these things I could get with formfields / fields, but it just would not "look & feel" that good and is too inflexible for me.

Daniel

fumei
05-10-2005, 09:06 AM
Best practice?

As Daniel mentions, a global template containing standard useful functions and procedures.

Specific templates are created by careful analysis of the requirements. Which means all that "boring" THINKING stuff. All that tedious consultation with the users of the template. However, the better the specs, the better the code.

The number 1 thing, for me at least, is to actually write it out. What are the needs? Write it out. Then I graph it out as a flow chart. There has never yet been a case where actually plotting the structure out has not caused a realization that it needed to work differently from my original concept.

"Maybe I could only use a userform tp populate the bookmarks in the header and footer, and for the other required field user protected sections with formfields.
Or, maybe use hidden tables with reqired form fields in protected sections to populate all of the bookmarks?"

Could you elaborate on the above? These are design elements. Are you saying that all documents require these? Maybe so, and if they are, then the result should be that they are there. But i am not clear on what you are asking.

MOS MASTER
05-10-2005, 10:28 AM
Hi and Welcome to VBAX, :D

I also agree with Daniel and Gerry!

Like Gerry I think that a good plan ussually saves you a lot of troubles in the End. (And don't forget a good plan saves TIME)

For the tools: Word has a tool for about everything you can come up with! So your specs will tell us what the best tool is.

I also am a Big fan of Global templates (*Dot files function as addin's from let's say Word startup folder)
These all have my favorite functions in them and a lot off UserForms for all sorts of tasks.

My Favourite combo is UserForms with Bookmarks. But fields or variabels will work just as well...it's preference for me (Of course it always has to do with what your looking for)

Enjoy! :whistle:

GrodanBoll
05-17-2005, 12:11 PM
Hi :hi:

Thanks for the answers and I'm sorry I have been a bit off.

In the first run of templates i used a global template to store all the code, then, in the specific template, I only called the diffent functions to polulate the userform and the bookmarks in the document.
In the global template I even stored all the user form fields in arrays and when I needed to create another template I only created a array for the template. The code then calculated and placed out the diffent form fields depending on the type of field, colum and row. All of that contained in the arrays. I used one general array for all the form fields that all the templates contained and one specific array for the specific template.

I thought I was smart... but Murphys law is way smarter then me. =/

The code became quite large and as created new templates I still was not satisfied with the bounderys of the system.

My goal is now to have as simple templates as possible (KISS). There of my question.

The templates need to contain fields for the user to write text, check a box and select a value from a list.
The written text should get straight to specifik places in the document (i.e. header and footer).
The values selected in the check box and select list should generate values to pecifik places in the document (i.e. header and footer).Here I am in two minds, either get values from a global template or from the code it self. The global template the "normalization" right, the code-style get the portability.

Further I don't want any user form because I think it is to much work.

In other word I guess I'd like to both eat and still have the cake.

:help

MOS MASTER
05-17-2005, 12:21 PM
Hi,

I would keep it stupidly simple! :rofl:

In your template add all the formfields you need.
If a formfield has to do something on enter or on exit have a macro assigned to the field. (On enter or leave) that will do that action!

If you want to fill out repeated entries (Values of the formfield somewhere else in the document), just go to that place and:
* Prest CTRL+F9
* Type the name of the formfield value you want. (IE:bookmark name)
* Update the fielf (F9)
* Go back to the formfield and put the property "Calculate on Exit" to true!

Updating fields in Headers and Footers needs some code.
For updating those values in Headers and Footers I have a Kb Entry submitted in the knowledge base. (But we can adjust that one to your specif needs)

So if I'm reading the specs correct you don't need any Global template but just a normal template with the customation described as above...

If this is not what you want ... then please provide more details.

Enjoy! :whistle:

Steiner
05-18-2005, 12:37 AM
Ok here's another approach (but only the theory as I would not use that myself and therefore did not think too much about it):

Instead of using formfields or something like that, simply use search & replace. You could use some special marker characters that won't appear in the text, eg:
#*-text for a box asking to enter text
#*-list for a listbox asking for a selection
...
Then think of a way to provide parameters, maybe:
#*-text#Enter your text here#This is default##

Where the # is the seperator and the ## marks the end of the call. Then insert those right into the document.

Now you need a macro (maybe in the global template) that simply looks for all calls that fit the above declaration, reads the parameters and constructs an user-interface (inputbox, small form with a list...) according to those settings. Then it just gets the user data and replaces the call with that data.

Daniel

GrodanBoll
05-18-2005, 08:54 AM
Thanks for your answers. :)
I'll think about it and test some code.

"I'll be back" as a (in)famous person once said. :)

Thanks again
/Grodan

MOS MASTER
05-18-2005, 10:01 AM
Hi Grodan, :yes

You're welcome, and please do come back and tell us your test results? :thumb