Page 1 of 2 12 LastLast
Results 1 to 15 of 25
  1. #1
    2 Star Lounger
    Join Date
    Nov 2001
    Posts
    119
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Making toolbar visible depending on text selected? (Word 2002)

    Hi,

    Any help on this would be much appreciated as it is pretty urgent.

    I am developing a custom application for one of my clients. One of the features is, I need to be able to 'switch' various toolbar and menu options on and off depending on what text is selected. Ie, something similar to the native Bold, Italic, Underline etc features which Word currently has. If the user selects a piece of bold text, the bold icon is activated.

    Also, is it possible to activate, or make custom toolbars visible depending on what text is selected?

    Any advice would be much appreciated [img]/forums/images/smilies/smile.gif[/img]

    Many thanks,

    Chris

  2. #2
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Making toolbar visible depending on text selected? (Word 2002)

    If you find a good way to do this then please let us all know. I have tried and given up. The nearest I could manage was with a Macro that kept running every 1/2 second using Application.Ontime - the side effects were worse than the solution.

    StuartR

  3. #3
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Making toolbar visible depending on text selected? (Word 2002)

    Bryan,

    Thank you <img src=/S/clapping.gif border=0 alt=clapping width=19 height=23> <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>

    If you had posted this in reply to my <post#=159306>post 159306</post#> it would have saved me a lot of time.

    Where is the WindowSelectionChange event documented? I certainly couldn't find it when I went looking on the MSDN web site.

    StuartR

  4. #4
    5 Star Lounger
    Join Date
    Jul 2002
    Location
    Toronto, Ontario, Canada
    Posts
    1,139
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Making toolbar visible depending on text selected? (Word 2002)

    You're welcome Stuart. Glad I helped you. Hopefully this'll help Chris.

    All I can say WRT to not replying to your post is Saved by the date <img src=/S/grin.gif border=0 alt=grin width=15 height=15> It was about a week before I joined the lounge.

    I just did a quick MSDN search on WindowSelectionChange and came up with these results.
    --
    Bryan Carbonnell - Toronto <img src=/S/flags/Ontario.gif border=0 alt=Ontario width=30 height=18> <img src=/S/flags/Canada.gif border=0 alt=Canada width=30 height=18>
    Unfortunately common sense isn't so common!!
    Visit my website for useful Word, Excel and Access code, templates and Add-Ins

  5. #5
    2 Star Lounger
    Join Date
    Nov 2001
    Posts
    119
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Making toolbar visible depending on text selected? (Word 2002)

    Bryan,

    Good job! Thanks [img]/forums/images/smilies/smile.gif[/img]

    This has certainly opened up quite a few doors for development.

    I'm actually working on a pretty interesting project at this end and I'll certainly keep you guys posted with how things go.

  6. #6
    5 Star Lounger
    Join Date
    Jul 2002
    Location
    Toronto, Ontario, Canada
    Posts
    1,139
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Making toolbar visible depending on text selected? (Word 2002)

    Glad it'll work for you.
    --
    Bryan Carbonnell - Toronto <img src=/S/flags/Ontario.gif border=0 alt=Ontario width=30 height=18> <img src=/S/flags/Canada.gif border=0 alt=Canada width=30 height=18>
    Unfortunately common sense isn't so common!!
    Visit my website for useful Word, Excel and Access code, templates and Add-Ins

  7. #7
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Springfield, Ohio, USA
    Posts
    2,136
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Making toolbar visible depending on text selected? (Word 2002)

    > Where is the WindowSelectionChange event documented?
    There is some material on the Selection Change Event and how to set it up in Broctor's book, Microsoft Office 2000 Visual Basic for Applications Fundamentals</u>. It was unfortunate that they added fundamentals to the title. It has a lot of information that I haven't seen elsewhere. --Sam
    <font face="Comic Sans MS">Sam Barrett, CACI </font face=comic>
    <small>And the things that you have heard... commit these to faithful men who will be able to teach others also. 2 Timothy 2:2</small>

  8. #8
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: Making toolbar visible depending on text selected? (Word 2002)

    Bryan,

    One caveat with WindowSelectionChange is that it seems to add a lot of overhead - at least I recall when playing around with it, it made the Word window behave very 'twitchily' - does the Word window appear to behave oddly when you use this?

    Gary

  9. #9
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Making toolbar visible depending on text selected? (Word 2002)

    I have added this to a global template and it's working fine.

    StuartR

  10. #10
    2 Star Lounger
    Join Date
    Nov 2001
    Posts
    119
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Making toolbar visible depending on text selected? (Word 2002)

    It seems to be working ok Gary. I guess the one thing to be careful of is not to put too much code inside the procedure. This may have an adverse affect on performance.

    Stuart, how do I include this inside a global template?

    Thanks

  11. #11
    5 Star Lounger
    Join Date
    Jul 2002
    Location
    Toronto, Ontario, Canada
    Posts
    1,139
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Making toolbar visible depending on text selected? (Word 2002)

    Honestly Gary,

    I haven't really used it for much, other than brief bouts of experimentation and I haven't noticed any appreciable slow-down, "twitchyness". or oddness, other than the normal Word oddness <img src=/S/grin.gif border=0 alt=grin width=15 height=15>

    Maybe it's because I have been using 1.4 & 1.5 GHz processors with 256 MB RAM and 32+ MB RAM video cards, that I haven't noticed it.

    Maybe I'll give it a shot on a Celeron 333 tonight and see what it does.
    --
    Bryan Carbonnell - Toronto <img src=/S/flags/Ontario.gif border=0 alt=Ontario width=30 height=18> <img src=/S/flags/Canada.gif border=0 alt=Canada width=30 height=18>
    Unfortunately common sense isn't so common!!
    Visit my website for useful Word, Excel and Access code, templates and Add-Ins

  12. #12
    5 Star Lounger
    Join Date
    Jul 2002
    Location
    Toronto, Ontario, Canada
    Posts
    1,139
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Making toolbar visible depending on text selected? (Word 2002)

    I'm not sure if one has to worry how much code is there, but how much code gets executed each time the selection changes.
    --
    Bryan Carbonnell - Toronto <img src=/S/flags/Ontario.gif border=0 alt=Ontario width=30 height=18> <img src=/S/flags/Canada.gif border=0 alt=Canada width=30 height=18>
    Unfortunately common sense isn't so common!!
    Visit my website for useful Word, Excel and Access code, templates and Add-Ins

  13. #13
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Making toolbar visible depending on text selected? (Word 2002)

    > Stuart, how do I include this inside a global template?

    Assuming that you have created an Event Procedure that works correctly, you just have to copy the template to your Word Startup folder, as specified in Tools > Options > File Locations

    StuartR

  14. #14
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: Making toolbar visible depending on text selected? (Word 2002)

    Hi Bryan,

    It occurred to me a little after posting, that this may have a lot to do with processor speed - when I last played with it, 'twas on my home PC (Pentium 2, 400 Mhz, 128 MB RAM) - maybe it's something that only recently stopped being an issue, since computer speeds have increased - be interested though to see how it runs on your old Celeron.... <img src=/S/snail.gif border=0 alt=snail width=21 height=17>
    <img src=/S/grin.gif border=0 alt=grin width=15 height=15>

    Gary

  15. #15
    5 Star Lounger
    Join Date
    Jul 2002
    Location
    Toronto, Ontario, Canada
    Posts
    1,139
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Making toolbar visible depending on text selected? (Word 2002)

    Gary,

    I just gave it a shot on my Celeron 333 160 MB RAM.

    No flakiness or twichiness on a 20+ page document created with the =rand() command.

    The only time it twitched was when I triple clicked in the left margin to select the entire document. And I think that was because I set it up to change the font colour and add text shadowing.

    Maybe it was something that was "fixed" in O2K SP1?

    I dunno. <img src=/S/shrug.gif border=0 alt=shrug width=39 height=15>
    --
    Bryan Carbonnell - Toronto <img src=/S/flags/Ontario.gif border=0 alt=Ontario width=30 height=18> <img src=/S/flags/Canada.gif border=0 alt=Canada width=30 height=18>
    Unfortunately common sense isn't so common!!
    Visit my website for useful Word, Excel and Access code, templates and Add-Ins

Page 1 of 2 12 LastLast

Posting Permissions

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