Word 2000 vs 97: User Forms Modal?

V

VBA Coder

Can anyone tell me if there was a change from Word97 to Word2000, where when
I create a User Form and have it Shown, it will always be Modal?

In Word2000, I can have my User Form loaded on top of my Document and I am
able to click around in the Document making changes or if I want to debug my
VBA code, I am able to step (F8) through my code and watch the changes take
place on my document. However, in Word97, with the exact same form and
code, I am not able to do this - the User Form appears to be Modal. I am
unable to click anywhere in my document - focus is always on the UserForm.

Thank you.
 
W

Word Heretic

G'day "VBA Coder" <[email protected]_SPAM.>,

This is correct. 97 does not support amodal forms.

VBA Coder said:
Can anyone tell me if there was a change from Word97 to Word2000, where when
I create a User Form and have it Shown, it will always be Modal?

In Word2000, I can have my User Form loaded on top of my Document and I am
able to click around in the Document making changes or if I want to debug my
VBA code, I am able to step (F8) through my code and watch the changes take
place on my document. However, in Word97, with the exact same form and
code, I am not able to do this - the User Form appears to be Modal. I am
unable to click anywhere in my document - focus is always on the UserForm.

Thank you.

Steve Hudson

Word Heretic, Sydney, Australia
Tricky stuff with Word or words for you.
wordheretic.com

If my answers r 2 terse, ask again or hassle an MVP,
at least they get recognition for it then.
Lengthy replies offlist require payment.
 
P

PeterS

-----Original Message-----
Hello,

This is correct. 97 does not support amodal forms.

Just because the question turned up. You're right, of
course, Word97 does not support amodal forms.
On the other hand there is a way to 'detach' the form from
Word using a buch of API calls -> 'EnableWindow'. I bet
you heard/saw/used it already.
(If not: Steve Bullen wrote that code for Ecxel97, and it
can be re-adjusted so that it works in Word97, too.)

So, can anybody tell me what the drawbacks of this method
are? I assume (I'd bet <g>) that the 'real' amodal form of
Word2000 would let you execute code contemporaneously; the
above mentioned method can't.

I actually want to use the modified code, and would like
to know a bit what I'm getting myself into. <g>


See ya
Peter
 
V

VBA Coder

Do you know where I can find "Steve Bullen's" code for Excel97? I would
like to see if I can get the Form to be a non-Modal form, that way I can
have my users minimize the Form and make changes to the document and then
Maximize my form to enter additional criteria, just like they can in my
Word2000 version.

Thanks.
 
J

JGM

Hi there,

What you are trying to do seems to be very complicated as there seems to be
a very simple solution.

You want users to go back in the document while having the form minimized
and then bring it back when they decide that they need it again... right?

So why no simply include a "Hide form" button on the form itself?
This button would
1) Hide the form (but keep it loaded in memory)
2) Add a button/menu item on the toolbar to bring the form back on demand...

Just a few lines of code as opposed to the very complicated API calls...

Just an idea...

Cheers!
 
V

VBA Coder

Yes, that would be easiest way and I did think of this, but was hoping to
get the same functionality as my Word 2000 template, which does allow you to
make the form Modal-less. Right now, I don't have any custom toolbar(s) or
menu(s) in my template where I can put this button to Re-Show the form if
the user Hides it, which is why I was trying to go with a Modal-less form.
I have not worked with adding/removing buttons from a toolbar before. Any
simple code you can send our way?
 
P

PeterS

-----Original Message-----
Thank you.

You are welcome.
I found "Steve Bullen's" web site,
http://www.bmsltd.co.uk/Excel/Default.htm. I will let
you know if I can get it to work in Word. It looks
pretty straightforward.

I played around with it a bit. Fairly simple, just import
the class module, change "XLMAIN" to "OpusApp" (in the
code), and that's it actually. No sweat. :)

So, the question remains: what am I getting myself into
with the use of this code? Drawbacks in Word200X?
(Actually all I need is the possibility to let the user
click at the text and modify it there, while the form is
still displayed.)

See ya
Peter
 
V

VBA Coder

Yes, I was able to get it to work in Word. By making my UserForm non-Modal,
I can allow my user to keep the UserForm open while they make changes to the
document. Then they can go back to the UserForm and re-enter criteria that
updates their document (via bookmarks and VBA code). Plus, I am able to
keep the UserForm open while I debug my application by stepping through my
code and watch what happens on my document - makes it real nice for
debugging purposes.

I did however, abandon this method for a much better method, but I will
leave it up to the end-user to decide which way they like best. I took
PeterS' suggestion to hide the UserForm with button, and create a Floating
PopUpMenu with a single button that will allow the user to "Show" the
UserForm:

Private Sub btnHide_Click

Me.Hide
ShowPopUpFormButton

End Sub

Public Function ShowPopUpFormButton()
Dim myBar As CommandBar
Dim graphBtn As CommandBarButton
Dim bFound As Boolean, sToolBarName As String

sToolBarName = "ShowForm"

' Check if the PopUp Form already exists. If so, just show it, otherwise,
create it
For Each myBar In CommandBars
If Left$(myBar.Name, Len(sToolBarName)) = sToolBarName Then
bFound = True
Exit For
End If
Next

If bFound Then
CommandBars(sToolBarName).Visible = True
Else
Set myBar = CommandBars.Add(Name:=sToolBarName,
Position:=msoBarFloating, _
Temporary:=True)
myBar.Visible = True
Set graphBtn = myBar.Controls.Add(Type:=msoControlButton)
With graphBtn
.Caption = "Show Form"
.Style = msoButtonCaption
.DescriptionText = "Show Form"
' When clicked, run the Macro to Show the Form
.OnAction = "ShowMacroForm"
End With
End If

End Function
 
P

PeterS

-----Original Message-----

H'ye,
I did however, abandon this method for a much better
method, but I will leave it up to the end-user to decide
which way they like best. I took PeterS' suggestion to
hide the UserForm with button, and create a Floating
PopUpMenu with a single button that will allow the user
to "Show" the UserForm:

Credits for this go out to Canada, not Germany. :)
Jean-Guy Marcil (JGM) was the one who suggested this.

I pondered that thought also, and since 'my' user often
just have to change a few (if not just one) character/s,
just for fun of it I played around a bit with the idea in
my head. - I probably won't use it, but you could just
hide the form /a few seconds/, and so giving the user
(with a looped DoEvents) the possibility to quickly edit
the document before the form comes up again.
Just a twisted thought. <g>

And since I'm a huge fan of keyboard shortcuts, I'd prefer
those instead JGM's toolbar. (Given, it's 'neater' to have
a button to click on, but you also can tell the user (with
a Label (preferred, users are usually not /that/ dumb), or
a MsgBox), to press those keys to get the form back.

.... I'm rambling... ;-}

See ya
Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top