Consulting

Page 3 of 3 FirstFirst 1 2 3
Results 41 to 51 of 51

Thread: toolbars

  1. #41
    ok then, if i dont want all the code and toolbars available to all users then

    and how do i get word to select the correct global template?

    did you look at my code in the file i sent you?

  2. #42
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    If you have 10 different templates, one would assume that they are used to create 10 different types of documents. NOT different documents with different data, but 10 different kinds of documents.

    The real question is: HOW are the users deciding which document to create in the first place?

    Document templates and global templates are both .dot files.

    Document templates are used to create documents. Documents made from templates are clones. They are EXACTLY like the .dot file. The intention is to create a new document EXACTLY like the template, then the user can input data, or text...something...that will make that particular document unique. The intention of a document template is to maintain a common look and structure.

    Say a Letter.Dot - a template for creating letters. It can have headers and footers, or logos, or whatever, plus Styles. ALL letters created from that template will have these common elements. The text content will change of course for each letter, but the look and structure will be the same for them all.

    Global templates are also .dot files. However, their purpose is quite different. They are intended to be code containers. They are intended to be used for all documents, regardless of document template used to create those documents.

    Globals templates can be used for toolbars or other user interface structures.

    Document templates can also contain code (and often do), and toolbars. However, these will only be available for documents created from THAT template.

    Do you want "stuff" - code, toolbars etc. - available for ALL documents? Use a global template.

    Do you want "stuff" - code, toolbars etc. - available for just the certain documents? Use a document template.

    Technically speaking, document templates do NOT have to be in the template directories recognized by Word. Calling a .dot file will create a new document from that template, regardless of how it is called. The template directories recognized by Word simply make them visible with File > New.

    For example: a global template (in Startup so it is loaded automatically) may have a button on a toolbar. That button can call a document template from anywhere. Or that global may have a menu dropdown which lists a number of templates. Letter, Finacial report, Staffing...whatever. The template file that is called by selecting one of those does not, technically, have to be in one of the Word template directories.

    I would agree with Steve that generally speaking, you should have one, or two, globals. I have ONE that is in Startup, so it loads automatically. However, it has buttons that load (and unload) other globals. They are NOT in Startup. This way I can load them as temporary globals.

    Going back to the question:

    "if i make up 10 templates all different, then when word is opened how will it know which one to open/use?"

    How do you WANT to determine which to use? What criteria, what logic, is used to decide which to use? Once you know that, actually calling the decided upon template is easy.

    "normal.dot is the general one which is used even if other templates are available, how does word know when to change which template to use, can or is it done via code?"

    This is not correct. Normal.dot is not used "even if" other templates are available.

    ALL documents have an attached template.

    If a document is not cloned from an explicit template (using File > New by menus; or created by code), then Word attaches normal.dot.

    ALL documents have an attached template. So if you do not explicitly tell Word - use THAT template - then Word will use the default template...normal.dot.

    Documents not created from an explicit template (ie. the attached template is normal.dot) may have a template attached to it after the fact. That is, an existing document can have a different template attached to it. Attaching a different template to an existing document supercedes the previous template. The previous template is no longer attached. Any code, or toolbars etc., that were in that previous template will no longer be available.

    "what if i want to make up more templates which go off say log in name

    or how do i determine which template is to be used when?"

    This is strictly, and only, a matter of logic. That logic has to be determined. These are decisions. Make the decisions. Writing the actual code for it is small stuff.

    I can not stress this enough. Writing code is (contrary to what many people think) the minor part of creating VBA applications. THINKING is the major part. VBA, like all programming languages, is based on the use of logic. It does not do ANY thinking for you. It follows rules. It does exactly what it is told. No more. No less.

    99.9% of the time if something is not going the way you want it to, it is because you have not told it the right thing.

    There is of course that wee bit that can only be described as the ghost in the machine.

    The problem is...unfortunately...the object model built may be weird. Word is a good example of that. It has some....odd...aspects. Some very infuriating aspects. It has aspects that are not intuitive at all. Some are decidedly counter-intuitive. They appear to make no sense at all.

    Nevertheless, they MUST follow logic. Skewed, twisted and even stupid logic at times, but logic none the less.

    So regarding whether to use template C, instead of template G...that decision is up to the coder (assuming it is being done with code). Telling Word to actually DO that...minor stuff.

  3. #43
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    99.9% of the time if something is not going the way you want it to, it is because you have not told it the right thing.
    I read the acronym that covers this in our forum the other day. Don't remember who shared it.

    It's called a picnic error. Problem In Chair Not In Computer

    There is of course that wee bit that can only be described as the ghost in the machine.

    The problem is...unfortunately...the object model built may be weird. Word is a good example of that. It has some....odd...aspects. Some very infuriating aspects. It has aspects that are not intuitive at all. Some are decidedly counter-intuitive. They appear to make no sense at all.

    Nevertheless, they MUST follow logic. Skewed, twisted and even stupid logic at times, but logic none the less.
    Word is different.
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  4. #44
    ok thanks for that fumei

    i am still looking through your message regarding the arrays and i am still trying to understand it fully and hoping to have a sample for you to look at soon....but i am puzzled by the sample code you wrote

    for var = 0 to ubound(MyList)
    Dropdown1.AddItem MyList(var)
    Next

    what is var? is it a variable?

    thanks for your help

  5. #45
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    You have a wealth of information here now. Thanks for that Gerry. I am going to bookmark this thread and use it for a reference.

    Yes, I looked at your code. You should put Option Explicit at the very top line of your module. Always use Option Explicit and you will know immediatly if you have errors....

    What exactly do you want to know about your code?
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  6. #46
    Sub Proforma()
    ' sets up the constant path
    Const Proformas As String = "x:\Mechanical\Master Blanks\Master PDF\"

    'sets up the top folders
    Dim Folders As Integer
    Folders = Array("Ukas", "Standard", "Master Specified")
    'sets up the subfolders
    Dim Ukas As Integer
    Ukas = Array("Micrometers", "Verniers", "Levels", "Force")

    Dim Standard As Integer
    Standard = Array("General", "Torque")

    Dim MasterSpecified()
    MasterSpecified = Array("General", "Micrometer", "Vernier")

    For Folders = 0 To UBound(Ukas)
    Dropdown1.DropDown.AddItem Ukas(Folders)
    Next

    End Sub

    this is what i have done so far but having trouble with the dropdwon part??

  7. #47
    not sure if i should have used integer?

  8. #48
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    dim them all as variant
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  9. #49

    dropdown

    still cant seem to get the dropdown to work?

    Dim DropDown1 As Variant

    For Folders = 0 To UBound(Ukas)
    DropDown1.AddItem Ukas(Folders)
    Next

  10. #50
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    don't dim the dropdown...dim the arrays as variant
    specifically in your last post....Ukas and Folders
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  11. #51
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    northernstar, I can admire you wanting to create relatively sophisticated VBA applications. However, the truth is...you are way over your head. You need to start learning some basics. You need to learn, and understand some concepts.

    Dim Standard As Integer
    Standard = Array("General", "Torque")

    WHY did you do that? WHERE did you get that from?

    To everyone else: northernstar PM'd me regarding arrays, and I responded with a very long reply, with examples. That is where he is getting some of the stuff above.

    HOWEVER, I most certainly did NOT give any example like

    Dim Standard As Integer
    Standard = Array("General", "Torque")

    The second line is setting an array. The first line is declaring a number.

    Sheeeesh.

    As Steve mentions, for goodness sake, use Option Explicit!!!! This has been mentioned to you before. The fact that you have the above code at all shows that you are not listening. If you had Option Explicit you would not being able to run that code at all...because it is WRONG.

    Where on earth did you get the idea of declaring it as an Integer????

    Sigh, I am sorry, but I am finding this too frustrating for the time being. Sincerely, all the best. Again, I really do respect that you are trying to do serious coding. I am just not attached to writing long, detailed explanations when they do not seem to actually help. I think you have received more than enough assistance from me, for now.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •