Solved

Change the size of a dialog box

Posted on 2002-07-16
11
167 Views
Last Modified: 2010-05-02
I don't know Visual Basic; however, I'm trying to help a user with a Visual Basic macro they have that was written in VB for MS-Word 97.  The macro goes through and counts paragraphs and then displays the first few words of each paragraph in a dialog box.  Then the user can go through and checkmark which paragraphs they want to include in their document.  For those paragraphs that are not checkmarked, the system will automatically delete them from the file.  My problem is that when there are a lot of paragraphs (more than 20), they don't all display in the dialog box.  Is there a way to change the SIZE of the dialog box in VB?  Please be very specific with your instructions, as I do not know VB.  THANKS.

0
Comment
Question by:esu4236
  • 5
  • 5
11 Comments
 
LVL 4

Expert Comment

by:gencross
ID: 7157885
What do you mean by dialog box?

Textbox, Richtextbox, listbox, etc...?
0
 

Author Comment

by:esu4236
ID: 7157918
Well, part of the macro has this code in it:

RemParasDialog.Show

So that's why I used the term "dialog box".
0
 
LVL 4

Expert Comment

by:gencross
ID: 7157920
It would be helpful to see the code.  Would you be able to post it?
0
 

Author Comment

by:esu4236
ID: 7157941
Maybe if you see this code, it will help also:

'This section creates the custom deletion dialog box for the
    'user. It makes a checkbox for each potentially deletable
    'paragraph, but ignores blank lines.
    For MakeBoxes = 1 To DeletableParas
        Selection.Extend Character:=Chr$(13)
        If Selection.Text = Chr$(13) Then
            Selection.ExtendMode = False
            Selection.MoveRight Unit:=wdCharacter, Count:=1
        Else
            With Selection
                .MoveUp Unit:=wdLine, Count:=1
                .MoveDown Unit:=wdLine, Count:=1
                .ExtendMode = True
                Selection.Extend Character:=Chr$(13)
                If Selection.Words.Count >= 5 Then
                    .ExtendMode = False
                    .MoveUp Unit:=wdLine, Count:=1
                    .MoveDown Unit:=wdLine, Count:=1
                    .ExtendMode = True
                    .MoveRight Unit:=wdWord, Count:=5
                End If
            End With
            CheckBoxLabel = Selection.Text & "..."
            Set ParaCheckBox(CheckBoxNo) = RemParasDialog.Controls.Add("Forms.Checkbox.1")
            ParaCheckBox(CheckBoxNo).Left = 12
            ParaCheckBox(CheckBoxNo).Top = (15 * (1 + CheckBoxNo)) - 10
            ParaCheckBox(CheckBoxNo).Width = 300
            ParaCheckBox(CheckBoxNo).Caption = CheckBoxNo & ". " & CheckBoxLabel
            CheckBoxNo = CheckBoxNo + 1
            Selection.Extend Character:=Chr$(13)
            Selection.ExtendMode = False
            Selection.MoveRight Unit:=wdCharacter, Count:=1
        End If
    Next MakeBoxes
   
    'With the custom dialog box built, display it. At this point,
    'program control will be turned over to the dialog box.
    RemParasDialog.Show
    If AbortFlag = True Then
        Exit Sub
    End If
0
 
LVL 4

Expert Comment

by:gencross
ID: 7157958
It looks like the dialog box is a form with checkboxes on it.  You have a couple of options...

Make the form scrollable or put the paragraphs inside a control that scrolls is all I can think of at the moment.

Let me work on it...
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 

Author Comment

by:esu4236
ID: 7157961
Well, I can't seem to delete this question, but I just found a FORM in one of the modules and all I have to do is change the size of the form and it will accommodate all my paragraphs.  THANKS.
0
 
LVL 4

Expert Comment

by:gencross
ID: 7157967
Have you tried to just change the size of the form and see if it works?
0
 
LVL 4

Expert Comment

by:gencross
ID: 7157971
Looks like you did :)
0
 

Author Comment

by:esu4236
ID: 7158017
Thanks, gencross, for your assistance.  Yep, I got it figured out.  It works okay now.  Thanks, again.
0
 
LVL 3

Accepted Solution

by:
schworak earned 200 total points
ID: 7158253
Really, it sounds like your best bet would be to make the form wide enough to show a reasonable amount of text and replace all that code that creates check boxes with a single list box that has a multi-select and check box capability. This way when there are too many items to fit on the screen the user can scroll down the list checking/unchecking what they like.

I have used this in templates that insert/remove various paragraph that are coming from a database so I would assume the situation you are dealing with would be similar.


Add a listbox named ParaList. The list box needs ListStyle=1 and MultiSelect=1 to reproduce what you are after.


You could then use this code...

ParaList.additem ParaList.ListCount+1 & ". " & Selection.Text & "..."




To replace all this code you now use...

CheckBoxLabel = Selection.Text & "..."
Set ParaCheckBox(CheckBoxNo) = RemParasDialog.Controls.Add("Forms.Checkbox.1")
ParaCheckBox(CheckBoxNo).Left = 12
ParaCheckBox(CheckBoxNo).Top = (15 * (1 + CheckBoxNo)) - 10
ParaCheckBox(CheckBoxNo).Width = 300
ParaCheckBox(CheckBoxNo).Caption = CheckBoxNo & ". " & CheckBoxLabel
CheckBoxNo = CheckBoxNo + 1

0
 

Author Comment

by:esu4236
ID: 7159388
Thanks, schworak, I'll give that a try.  Sounds like that might be the ticket.  I did make my dialog box bigger in the form; however, the user has so many variable paragraphs that they are still not going to be able to see all of their options unless they have a 19" monitor.  So your suggestion may work where they can actually scroll in the box to see all of their paragraph choices.

Thanks again!!!

0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now