• WSTroyWells

    WSTroyWells

    @wstroywells

    Viewing 15 replies - 331 through 345 (of 355 total)
    Author
    Replies
    • Regarding the “Weird” comment, I must have created this and moved it somewhere else and forgot to remove it here. You are right to say that is unnecessary. Good catch!!

      Regarding the Cancel and Terminate issue: You were right!! I had a lot of code in there I didn’t need. Once I removed this code the problem went away. I still don’t know which part of the code that I deleted caused the problem I was experiencing, but I think it would be best to not worry about that until it happens again.

      Thanks again for all your help!!
      Troy

    • Edited by TroyWells on 03-Sep-01 18:53.

      UPDATE: I had the wrong attachment attached. Sorry for any confusion. bash
      Troy

      I agree that my problems where caused by my use of the “Exit” event. So I changed the “Exit Event code to the “Terminate” event.

      KEY: What I was trying to accomplish with this code is to make the control menus (right-click on the title bar and click “Close”, ALT+F4, and the little “X” in the upper right corner do the same thing as the “Cancel” button. (Sorry, I probably should have mentioned this in my first post.)

      PROBLEM: When I put the same code in the “Terminate” event, as soon as I show the main form, it resets all the properties to whatever they were when the form was activated.

      For example:
      1. Run the form.
      2. Click on the Options button or the check box.
      3. Click a check box, and click OK.
      4. Click the Options button.
      5. Right-click on the title bar and click “Close”, or press ALT+F4, or click the little “X” in the upper right corner.
      The main form reappears but the options on the other form are reset to their default (i.e. it doesn’t retain the check mark you applied in step 3.

      I tried commenting out “frmFormatDocumentMain.Show”, but all that does is return the focus to the document with the form still visible. Once I click the form again (i.e. the form gets the focus) it resets everything.

      I have attached the document including changes I made in response to your first reply.

      Thanks again for your help!!
      Troy

    • in reply to: Sorting list boxes in VBA (Word 2000 VBA) #539035

      Thanks to all who gave such wonderful and teaching advice. I learned a lot from all of you. Feel free to continue if you have something to add, but at this point, I think I am going to go with Geoff’s solution.

      HOWEVER, I found that I need to add a couple of lines or I ended up with an endless loop if I moved one item to a list that was already empty:

      ‘Added this first “If line and the corresponding “End If” below
      If lbIncludeTextIn.ListCount > 1 Then
      Dim blnSorted As Boolean
      Dim strTemp As String
      blnSorted = False
      Do Until blnSorted
      For i = 0 To lbIncludeTextIn.ListCount – 2
      If LCase$(lbIncludeTextIn.List(i)) > LCase$(lbIncludeTextIn.List(i + 1)) Then
      strTemp = lbIncludeTextIn.List(i)
      lbIncludeTextIn.List(i) = lbIncludeTextIn.List(i + 1)
      lbIncludeTextIn.List(i + 1) = strTemp
      Exit For
      End If

      If i = lbIncludeTextIn.ListCount – 2 Then
      blnSorted = True
      End If
      Next
      Loop
      End If

      Thanks BigKev for the QuickSort demo. It was quite honestly over my head doh. I couldn’t quite figure out how it worked or where to put the list name.

      Thanks Gary for the referral to MS OfficePro. My trial period just expired, but I think I’m going to buy a subscription. Seems like there is a lot of good stuff there.

      Thanks also to jscher2000 for your posts. You started me off simple, which helped me understand the more complex posts of yourself and others.

      I look forward to seeing what you have Chris. Let us know when your site is back in working order!! Thanks also to Kevin for your initial post.

      You guys are the best!!
      Troy

    • in reply to: Sorting list boxes in VBA (Word 2000 VBA) #538784

      I think we may be halfway there. I can get to your home page and look around (impressive!) bravo, but when I try to download anything, I get a page that says “Page not found”.

      Thanks again for your help!!
      Troy

    • in reply to: Sorting list boxes in VBA (Word 2000 VBA) #538705

      Edited by TroyWells on 23-Aug-01 11:37.

      Geoff,
      Please see problem in 3.b below
      In the interest of learning brainwash, I had a few questions about the code below:
      1. Could you give a breif explanation of what a “Bubble Sort” is? I have heard this term before, but did not understand it.
      2. What is the advantages/disadvantages of this code over what “jscher2000” posted below yours? Or is it just a different approach?
      3. I don’t quite get what is happening in your first “If” statement. Obviously, this is the guts of the Bubble Sort, but I’m not sure I get what is happening. As I look at it, it seems you are looking at the first item in the list and comparing it to the second item. If the first item is greater (further down the alphabet or has a higher character code), you are switching the places of the first and second item in the list and so on to the end of the list.
      a. What is the purpose of the “strTemp = lbIncludeTextIn.List(i)” statement. It doesn’t appear that you use “strTemp” later anywhere, so why do you define it here?
      b. In the statement “lbIncludeTextIn.List(i) = lbIncludeTextIn.List(i + 1)”, what keeps “List(i)” from overwriting “List(i+1)”,
      and visa-versa in “lbIncludeTextIn.List(i + 1) = lbIncludeTextIn.List(i)”? In fact, in my testing that seems to be exactly what happens!! Every item in “lbIncludeTextIn” is now named the same as what was previously the first item in the list.

      Thanks for your help!!
      Troy

    • in reply to: Sorting list boxes in VBA (Word 2000 VBA) #538707

      Chris,
      Thanks for your reply. Unfortunately, I cannot access the link you included. If I put the full link it says “Page not found”. If I put in part of the link, it says I am not authorized to open the page.

      I’d love to see these utilities.

      Thanks!!
      Troy

    • in reply to: Sorting list boxes in VBA (Word 2000 VBA) #538703

      You know what? This actually works, MOSTLY.

      How do I get it not to consider the case? For instance, I want “Test1” to come before “test2”. Right now “test2” comes first because it has a lowercase “t”.

      One other question, just for my learnin’: What does the “Me.” do when you add it before the list box name as you did 4 times below?

      Thanks!!
      Troy

    • in reply to: Sorting list boxes in VBA (Word 2000 VBA) #538689

      Thanks for your response. I tried to follow what you gave me but I am getting a run time error.

      Let me give you what I have:

      ListElements is my array.
      lbIncludeTextIn is my list box.

      This is my code:

      Dim ListElements() As Variant ‘Dimming my array.

      ListElements() = lbIncludeTextIn.List ‘Adding list items to my array.
      WordBasic.SortArray (ListElements()) ‘Sorting the array.
      lbIncludeTextIn.Clear ‘Emptying the current contents of the list box.
      lbIncludeTextIn.List = ListElements() ‘Filling list box with sorted contents of array.
      End Sub

      Thanks for your help!!
      Troy

    • in reply to: Moving from listbox to listbox (Word 2000 VBA) #538033

      Thanks for the demo!! I couldn’t tell for sure how you made them sort properly.

      Getting them to go back and forth is no problem now. I actually have 3 lists and I have two buttons between each list to go in either direction. Appropriate buttons are displayed and enabled, displayed and disabled from the click event of each list box.

      Now, I have searched around the vba lounge for a way to have these sort alphabetically. This is an issue because I will be adding random names to these lists and would like them to automatically be sorted. I figure the code could be put in the Change event for the list box. But what I need is the how to sort in a list box (one column, could include letters or digits). I have seen some of your responses in other posts, but they seem far more complex than I need.

      Thanks again for all your help!!
      Troy

    • in reply to: Moving from listbox to listbox (Word 2000 VBA) #538024

      I though that worked great!! However, one problem, when I selected the last item in the list and clicked the command button to move them, it moved that item and the item above it, which was NOT selected.

      I thought that may have had something to do with the MultiSelect property (set at the time to “fmMultiSelectSingle”) on my ListBox. So I changed it to “fmMultiSelectExtented” which is what I wanted anyway. Then I found that selecting an item did not activate the command buttons as it had previously. It also did not deselect when I clicked on an item in another list. This was working when I used “fmMultiSelectSingle”. I know this is a different issue than I asked before, but would appreciate any help you could give.

      Also, I want to learn a little more about the code you sent. I may not use the right terminology, so please correct me when I’m wrong.

      intcounter is what, a function, a method? I couldn’t find any info about it on msdn or in the online help for vba. Or is it an ingenious combination of “int” and “counter”?

      It appears to count as you say from the last item in the list (which is the total of the items in the list minus 1 because the ListCount starts at 0. Right?

      Is this the only way to refer to items in a list box? It appears the ListEntry object only applies to drop-down lists. This was probably my biggest hangup. I was trying to use a For Each statement and Dimmed “li” as a ListEntry.

      I think I get the rest. Thanks for taking the time to help and educate a newbie!! doh

      Troy

    • I wanted to reply to give the full path to each of these documents, at least as of today, in case someone else goes and looks for them. Gary, you gave me enough to get me there, but it still wasn’t easy (no fault of yours), so I wanted to put it all down here for the sake of others. The paths are really not even close after the first level of the TOC.

      For Office 97 Visual Basic Programmer’s Guide:

      http://www.msdn.microsoft.com/library/

      Then in the Table of Contents in the left pane:

      Office Solutions Development
      Microsoft Office
      Microsoft Office 97
      Product Documentation
      Office
      Microsoft Office 97/Visual Basic Programmer’s Guide

      For Office 2000 Visual Basic Programmer’s Guide

      http://www.msdn.microsoft.com/library/

      Then in the Table of Contents in the left pane:

      Office Solutions Development
      Microsoft Office Developer
      Microsoft Office 2000 Developer
      Microsoft Office 2000/Visual Basic Programmer’s Guide

      Enjoy!!
      Troy

    • Gary,
      You mentioned the “Office 97 and Office 2000 VB Programmers Guides”.

      I tried searching MSDN for these but am having a hard time finding them. You don’t happen to have them bookmarked do you? Or have some other clues to help find them.

      Thanks!!
      Troy

    • in reply to: Finding unused styles (Word 97 VBA) #535165

      This works beautifully. Thanks for your help!!
      Troy

    • in reply to: Finding unused styles (Word 97 VBA) #535078

      No problem about being crabby. I get that way to sometimes. hairout

      As far as the changes, let me tell you the affect:

      1. The macro now looks through a list of all built in styles in Word, not just the list of built in styles stored in the document. So the of built-in styles included in the output list is much longer now than the number of built-in styles actually stored in the document.

      For example, when I look at the styles stored in my document in Organizer (Format>Styles>Organizer command button), among others I see the following styles that start with “L”

      Labels
      Letter
      List
      List 10+
      List sub
      List+RTab
      List Button
      List Number

      (Some of this are built-in and some are not.)

      The styles found included:

      Labels
      Letter
      Line Number
      List 10+
      List 2
      List 3
      List 4
      List 5
      List Bullet
      List Bullet 2
      List Bullet 3
      List Bullet 4
      List Bullet 5
      List Continue
      List Continue 2
      List Continue 3
      List Continue 4
      List Continue 5
      List Number
      List Number 2
      List Number 3
      List Number 4
      List Number 5
      List sub
      List+RTab
      ListButton
      ListNumber

      2. One other side affect (which I have also seen after trying to use the Find function (CTRL+F) to find a built-in style that actually was not stored in my document) is that now all the built-in styles contained in Word appear in the Organizer as styles stored in this document. That gives me more styles I will have to delete and more work later.

      Hey, here is an interesting thought. After solving the problem mentioned above (and I would like the ability to list the unused styles despite what I am about to ask), could we add a line of code to this macro that would delete these unused styles from the document?

      Thanks again for all your help!!
      Troy

    • in reply to: Finding unused styles (Word 97 VBA) #534940

      Thanks for the response. Sorry you got shafted by WordTips. I was kind of surprised because I have gotten a lot of good information from them. Oh well, I guess noone’s perfect.

      Speaking of which, this macro ran great, EXCEPT:

      It only showed unused user defined styles. I want to also see unused built in styles. Any suggestions/additions to the original macro that could accomplish this?

      Thanks again for your help!!
      Troy

    Viewing 15 replies - 331 through 345 (of 355 total)