I'm still working my way towards the envelope maker. Here's a side-trip into creating a GUI form.

If you've never created a GUI form before, relax. It ain't as hard as those who make money out of teaching you would have you believe. And GUI forms are worth their weight in gold. Testing/checking what the user types in BEFORE making use of data saves many a crash.

Over the next few days I'm posting the steps I take to make a GUI form. I'll do this just for the envelope application. Future postings that need GUI forms will refer back to this form for the essentials.

For those of you who can't wait, or just want to know if there's anything excitingly new about what I do (as compared to what you do), you can hie ye off to <A target="_blank" HREF=http://www.vif.com/users/cgreaves/frmheadr.htm>http://www.vif.com/users/cgreaves/frmheadr.htm</A> and check out the finished product.

Those of you who are timid can go there too to verify this statement: There's not a lot of work in creating a GUI, and there's nothing complex.

"""""It's not complicated; it's just NEW."""""

For those of you MVP-types who GUI on a daily basis, I'd really appreciate your comments on the detail and accuracy of these instructions.

I'm still digesting James's comments of yesterday.

Now for the real posting. What follows below is enough (I hope) to get you to create a GUI form with a real, live, functioning "OK" button. We'll add detail as the days go by.


This template serves only as a vehicle for the GUI form "frmHeader". It can be found for the time being at http://www.vif.com/users/cgreaves/frmheadr.htm

You can either drag the frmHeader into your template, or you can follow the instructions below and create your own from scratch.

Purpose of the GUI form

We want to give the user a means of communicating with the INI file. The INI file is just plain ASCII text. The user could use Notepad.exe to edit it, but GUI forms permit a friendlier approach. Besides which, with a GUI form we can always check data for accuracy before storing it back in the INI file. With some user applications this is advisable!

Creating the GUI form

In the Word97/Visual Basic Editor (VBE) with your current template active, choose Insert, Userform.

You'll see appear a grey box.

Tap the F5 function key once; you'll be switched into word with a blank GUI form in front of you. Click on the "x" (top right-hand corner) to close the GUI and return to the VBE.

In the VBE if you don't see the ToolBox, choose View, Toolbox.

Drag a command button from the Toolbox to the GUI form. It will appear selected (handles at corners) and will contain the text "Command Button 1".

Tap the F5 function key again; into Word we go. Clicking on the button has no effect - yet. Close with the "x".

Back in VBE make sure the command button is selected then right-click on it; choose Properties from the pop-up menu. Activate the "Alphabetic" tab.

Change the name of the button to "cmdOK"; I like to use the prefix "cmd" for any thing that the end-user can touch or command.

Change the Caption to "OK".

Tap the F5 function key again; into Word we go. Clicking on the button has no effect - yet, but at least it LOOKS like on OK button! Close with the "x".

Back in VBE click in the GUI to make sure that the button is NOT selected, then double-click on the OK button (we are in the VBE, not in Word).

You'll fall into a code module with this code already in place:

<pre>Private Sub cmdOK_Click()

End Sub

In the blank line between "private sub" and "end sub" type or paste this line:

<pre>Unload me

Tap the F5 function key again; into Word we go. Clicking on the button HAS AN EFFECT. It WORKS like on OK button!
There. Wasn't that fun?

I added a comment to my code:
<pre>Private Sub cmdOK_Click()
' This procedure terminates all presence of the GUI form.
Unload Me
End Sub