Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / February 2006

Tip: Looking for answers? Try searching our database.

Hide X button on VBA forms

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
erin.sebastian@cowaninsurancegroup.com - 10 Feb 2006 16:31 GMT
Hello All,
I am just wondering if it's possible at all to disable or hide the X
button on the top right hand corner of a word VBA windows form? The
form in question is a sub form of the main form in my application, I
want the user to be able to open the form, click off some options and
then close the form, when the form closes however (via the cmdbutton
close) it hides the form so that if they go back into it the options
they chose are still clicked off, if the user however clicks on the X
it disposes of the form and the options are gone.. so i don't want them
to be able to click the X at all...
Thanks in advance for your time!!
Erin
erin.sebastian@cowaninsurancegroup.com - 10 Feb 2006 16:45 GMT
Hi All
I found a way to do it, via the Microsoft Word MVP site (which is a
great reference tool - http://word.mvps.org/FAQs/MacrosVBA/index.htm)
In the queryClose event of the userform you can put this code
  If CloseMode = vbFormControlMenu Then Cancel = True
which will intercept the closing of the form and cancel it all
together.

Thanks,
Erin
Jean-Guy Marcil - 10 Feb 2006 17:17 GMT
erin.sebastian@cowaninsurancegroup.com was telling us:
erin.sebastian@cowaninsurancegroup.com nous racontait que :

> Hi All
> I found a way to do it, via the Microsoft Word MVP site (which is a
[quoted text clipped - 3 lines]
> which will intercept the closing of the form and cancel it all
> together.

Make sure you tell the user what is going on, I would hate to click on the
X, expect the form to close, but instead, nothing happens, click again,
nothing again...
For example:

If CloseMode = vbFormControlMenu Then
   MsgBox "You cant quit like that!"
   Cancel = True
End If

Or tell them to use your own buttons instead.

Personally, I prefer to disable it, so visually, the user knows the X is not
functional.
See:
   http://word.mvps.org/FAQs/Userforms/DisableClose.htm
Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org 

Karl E. Peterson - 10 Feb 2006 17:40 GMT
> I found a way to do it, via the Microsoft Word MVP site (which is a
> great reference tool - http://word.mvps.org/FAQs/MacrosVBA/index.htm)
> In the queryClose event of the userform you can put this code
>    If CloseMode = vbFormControlMenu Then Cancel = True
> which will intercept the closing of the form and cancel it all
> together.

That's a *great* technique.  That is, *IF* you treat the [X] identical to
the "Cancel" button.  No Cancel button?  Disable instead.
Signature

Working without a .NET?
http://classicvb.org/

erin.sebastian@cowaninsurancegroup.com - 10 Feb 2006 18:54 GMT
thank you very much!!! i've disabled the close button!
Jonathan West - 10 Feb 2006 17:04 GMT
> Hello All,
> I am just wondering if it's possible at all to disable or hide the X
[quoted text clipped - 8 lines]
> Thanks in advance for your time!!
> Erin

How to disable the X close button on a UserForm
http://word.mvps.org/FAQs/Userforms/DisableClose.htm

Signature

Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org 


Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.