Consulting

Page 2 of 3 FirstFirst 1 2 3 LastLast
Results 21 to 40 of 51

Thread: toolbars

  1. #21
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    Sorry, but IMO, if you do not have a solid basic knowledge of how Word works, then what on earth are you doing working with macros and hundreds of files?

    answer 1 - the only macros i have are in a custom toolbar, not sure what you mean when you ask if the files are in my normal.dot?? yes i would like all of the files combined into this template providing it doesnt mean rewriting ot copy them into this template (unless there is a quick way as i have hundreds of these) and they have all been made up on many different pcs
    The above statement is so full of misconceptions, and misunderstandings that I am almost speechless.

    1. You MUST learn to understand where VBA code is. The statement above clearly shows you have no idea where code is, or where it is run from.

    "the only macros i have are in a custom toolbar"

    WRONG, WRONG, WRONG.

    Macros (procedures) are not in toolbars. The objects (icons, buttons, menu etc.) in toolbars are pointers to procedures. Procedures are in code modules.

    2. Code modules can be in four places:

    normal.dot
    the attached template
    a global template
    the document itself

    3. Recorded macros by default are written to normal.dot. This is a Microsoft decision. However, even Microsoft itself states that this is NOT a good idea. Normal.dot gets corrupted easily. Whenever possible, procedures should be written to a template file, but NOT the normal.dot template file.

    4. Efficient and proper use of Word revolves around templates. Actually understanding this is crucial. From the quote above:

    "yes i would like all of the files combined into this template providing it doesnt mean rewriting ot copy them into this template "

    What do you mean "rewriting"? And you do not "copy" into a template. I have no idea what you mean by "combined". Again, you clearly do not understand the basic structure of Word.

    ALL documents use a template. If one is not explicitly attached, then Word uses normal.dot. As normal.dot does, in fact, get corrupted easily, best-practice demands that you use an explicit template when creating documents.

    Yes, you can certainly apply ("attach") a template to hundreds of document if you want. There is a method to do so.[vba]Sub AttachABunch()
    Dim file
    Dim FilePath As String
    FilePath = "C:\whatever\"
    file = Dir(FilePath & "*.doc")
    Do While file <> ""
    Documents.Open FileName:=FilePath & file
    With ActiveDocument
    .AttachedTemplate = "C:\Templates\Letter.dot"
    .Save
    .Close
    End With
    file = Dir
    Loop
    End Sub[/vba]This would open every .doc file in the c:\whatever folder and attach the template Letter.dot to each document.

    Note that the template file (letter.dot) can be anywhere. It does not have to be the the Workgroup folder, or the userTemplate folder. It can be anywhere.

    Once attached, ANY code in that template will be accessible to the document.

    In terms of code accessibility, here is how it goes:

    Code in normal.dot - can be executed in any document.

    Code in a loaded global template - can be executed from any document.

    Code in the attached template - can be executed from any document created by that template, or any document that has had the template attached to it.

    Code in the document itself - can be executed only from that document.

    Let's see if I can make this very clear.

    Your question (if I understand this correctly) is this:

    How do I have a bunch of existing documents to show a NEW toolbar?

    There are a couple of answers, and which one is appropriate depends on EXACTLY the situation regarding those documents, and your network.

    1. Make a template file and open all those files, and attach it.

    2. Make a global template and then have each PC's normal.dot load it. You can also use Windows OS level scripting to do this.

    3. Put the toolbar in each PC's normal.dot.

    Look, I know it may seem like I am being hypercritical, but you have to do some work. I spend hours and hours of my own time helping people here and on other forums. The point is YOU have to do some work.

    If you are going to try and do advanced work with Word, you MUST work at understanding Word. How can it be otherwise? Also remember that all of us, myself included, all started from scratch. We all started not knowing anything. We got to know things by hard persistent work.

    And...it is not easy. The Word Object Model can be very very weird at times. The point is though is that no person can do serious advanced Word VBA without understanding Word.

    And it is an on-going learning. It never stops. I am still learning, still finding stuff out that I had no clue about.

    So relax, and think about what you are posting. Do as much research as possible. Use Help constantly. And please, really, think about what you are posting. Here is an example:
    i have setup a custom toolbar which stays open as long as i have ticked it on the dropdown menu, but if i unclick it then open a new or existing file then it doesnt appear
    Read that. Read it again.

    WHAT "dropdown menu"? How did it get there? What is on that menu? "stays open"???? What does that mean? A toolbar is not "open". It is visible, or not visible. Is this dropdown menu on the View menu? Is your toolbar listed there? If you unclick it - thus making it not visible - why on earth would you expect any new document to have it visible?

    It would be visible in any new document if it was properly in a global template, or normal.dot.

    Which is why....learn about templates. THAT is where your code is.

    Think. Good questions will never be ignored.

  2. #22
    here is a file which has the code in which i am using

  3. #23
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    That file is useless and pointless to the question you are asking.

    There are no toolbars which is - if you look at the title of YOUR thread - rather the point, is it not?

    The multiple Subs is VERY bad coding form.

    You have no way to even start any processes at all. Never mind any toolbars.

    WHAT toolbars????

    You are making a .dot file, a template, but you have NO CODE to execute anything when you make a new document from it!

    If you make a new document from this template absolutely nothing will happen.

    You do not even have any way to choose any of those Subs.

    All those separate Subs with the ChangeFileOpenDirectory - you have 12 of them - can be done with ONE Sub. Learn to use arrays.

    Learn to use constants.

    But back to what you posted, what YOU asked. There is nothing regarding toolbars in this file whatsoever.

    You are wasting my time. I don't care about the code you are using. It is not very good code. I actually DO care about helping you make better code. And I really DO care about helping answering reasonable and accurate questions. You are doing neither.

    Do you want to know about toolbars and how to use them. Then show me. This file has nothing of any relevance to this thread. It is more than useless, it is annoying.

    I will repeat it: if you make a new document from this template nothing will happen. You will get a blank document. How very useful. How are you going to get a user to execute anything?

    How are you going to get

    Sub General(), or
    Sub STANDARD(), or
    Sub SPECIFIEDMICS(), or
    Sub SPECIFIEDVERNIERS(), or
    Sub SPECIFIED()

    to run? NOTHING will run unless you tell it to do so. And you don't.

    And there is nothing at all with toolbars here.

    You mentioned:

    " have setup a custom toolbar "

    Not in this file there isn't. Which again makes this more than useless, it is annoying and a waste of my time. I have tried to help, and I would help if I could. But there seems to be nothing I can do.

  4. #24

    toolbars

    sorry if you think i am wasting your time.....that is not my intention

    i thought that the toolbar was saved to that file which was a template and not a .doc file???

    i am very keen on making my code better as i know its not that good but i am only learning in my spare time and just try to get thgrough what i can when i can

    so how can i attach my custom toolbar to the file to send to you?

    thanks

  5. #25
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    so how can i attach my custom toolbar to the file to send to you?
    see post #11 and look at question # 2 in that post.
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  6. #26
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    Oh please do misinterpret what I am saying. I certainly do not think you are trying to waste my time.

    I will say it again. You need to start to understand how Word works, and you must actually read the posts that people post. The fact that you have to even ask:
    so how can i attach my custom toolbar to the file to send to you?
    shows that you do not understand some basics of Word.

    What you posted is template (.dot) file. Why do you not create the toolbar in it? That is the point - which has been stated to you - of templates. It has also been clearly stated that Word will put code/toolbars etc etc. into normal.dot by default. So, YOU have to explicitly put it/them into your template. You.
    i thought that the toolbar was saved to that file which was a template and not a .doc file???
    You think that because you do not understand the basics of how Word, and templates, work.

    There is nothing inherently wrong with that. We ALL started not knowing. We learn by study and asking questions.

  7. #27
    thanks for all your help, i think i have sorted the template problem and i have it working on two pcs, just need to put it on the rest

    thanks again

  8. #28
    Site Admin
    The Princess
    VBAX Guru Anne Troy's Avatar
    Joined
    May 2004
    Location
    Arlington Heights, IL
    Posts
    2,530
    Location
    Northernstar: Here's a few articles that may help you, should you choose to take the time to read them. I've placed them in order of what I believe to be their importance in understanding Word...
    1. http://www.officearticles.com/word/a...osoft_word.htm

    2. http://www.officearticles.com/word/t...osoft_word.htm

    3. http://www.officearticles.com/word/w...osoft_word.htm
    ~Anne Troy

  9. #29

    thanks

    thank you very much.....i will have a look at them and hopefully they will help me no end

    thanks again

  10. #30
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    Anne, you are such a sweetie.

  11. #31

    new template

    please find attached a copy of the template which appears to be working on my network now, thanks for asll your help and any comments/advice would be appreciated

    thanks again!

  12. #32
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    Now you're headed in the right direction...
    The code was password protected so I couldn't look at it but that doesn't matter. You have made the basic error of using the normal.dot instead of renaming it to some other name and put it in the startup folder. If it is named normal it will conflict with other users on the network who already have a normal.dot.
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  13. #33

    toolbar

    thanks for that

    the password is 2729

    it is saved in a different location on the network

    i will rename it now

    thanks

  14. #34

    toolbar & template

    hi

    now i am heading in the right direction, 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?

    thanks

  15. #35
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    Sounds like you got things hashed out. If each user points their startup directory at the directory on the network where your file is located you will be in business.

    You can change the file and all users will see the changes when they run Word.
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  16. #36
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    how do i determine which template is to be used when?
    If they are in the shared network directory and the users have pointed to that directory for startup then all templates in that directory will run when they start Word.

    I should qualify that by saying that the code will not actually run but will be available to be run by all.

    Code that gets username/login name info will still work and will reflect the user who runs the code at that moment in time.
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  17. #37

    toolbars & templates

    so correct me if i am wrong here

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

  18. #38
    not sure why i would want to make up 10 different templates but i am trying to understand how templates work

    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?

    thanks

  19. #39
    did you get a chance to look at my code?

    would appreciate any comments / advice

    looking at creating arrays at the moment to condense all the procedures into one

  20. #40
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    Quote Originally Posted by northernstar
    so correct me if i am wrong here

    if i make up 10 templates all different, then when word is opened how will it know which one to open/use?
    These are .dot files but they are not being used as templates. They are being used to store toolbars and code. You should only have one of them and it should contain all of your toolbars and code that you wish to make available.

    Template for file creation or cloning go in your templates directory and are available under file-new....they are two completely different things.

    You can have code in your global that creates a new document from any of your template files....

    Normal is the template that word uses as a default to create a new blank document...you can change that if you wanted to but why would you.
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

Posting Permissions

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