elle0612
Fri Sep 01 05:50:01 CDT 2006
Hi
I think I've fixed it all. Like an idiot I wasn't making word visible again
after running all my code, therefore all the open documets at the bottom were
there, they were just invisible. That has now been fixed, what an idiot!!
So, if my document starts ok with no documents open, then the application is
hidden and exit button can be pressed (I've included application.visible at
the end just in case, but probably don't need it as the application closes.)
If there are documents already open, word becomes visible, a message box
appears to say "save and close all documents". When ok is pressed the open
documents appear for saving/closure. Then my application can be started up
again.
I put the code to count the documents in the userform_activate sub so now,
unless I'm mistaken and am missing something yet again (its very difficult to
discover problems until its used properly by other people I think) it seems
to work ok. Thanks very much for your advice and time. The only thing to
sort out now is my headache!!
"elle0612" wrote:
> Hello
>
> this is all the code that affects the userform
>
> Sub autonew()
> '
> ' autonew Macro
> ' Macro created 15/08/2006
>
> Application.Visible = False
>
> UserForm1.Show
>
> End Sub
>
> ---------------------------------
>
> Private Sub UserForm_Activate()
>
> tbxOne.SetFocus
>
> End Sub
>
> ---------------------------------
>
> Private Sub UserForm_QueryClose _
> (Cancel As Integer, CloseMode As Integer)
> 'Prevents use of the 'X' button
> If CloseMode = vbFormControlMenu Then
> MsgBox "Please Use the Exit button"
> Cancel = True
> End If
> End Sub
> ---------------------------------------------------
> Private Sub btnExit_Click()
> Application.Quit wdDoNotSaveChanges
> End Sub
>
> Thanks for your help.
>
> "Jean-Guy Marcil" wrote:
>
> > elle0612 was telling us:
> > elle0612 nous racontait que :
> >
> > > Thank you.
> > >
> > > Where would be the best place to put this code?
> > >
> > > In the macro editor screen?
> > >
> > > Finding out where to put code such as this is the trickiest part. I
> > > know that putting it in an event such as a button press is pointless
> > > here since everything would have loaded by that stage and the only
> > > way to get out of the userform is to press the Exit button since I
> > > have disabled the "X", so bye bye all open files!!
> > >
> > > The 'If documents.count >1' code would have to be run the minute
> > > after the user starts up the document, perhaps I could issue a
> > > message box to say "save your documents before using this
> > > application", and then hide the userform and close the active
> > > document.
> > >
> > > So please can you offer any advice on where to put the code for the
> > > best results.
> >
> > First, you have to tell us how you instantiate the Userform. Where is the
> > code that creates/launches the userform?
> >
> > --
> > Salut!
> > _______________________________________
> > Jean-Guy Marcil - Word MVP
> > jmarcilREMOVE@CAPSsympatico.caTHISTOO
> > Word MVP site:
http://www.word.mvps.org
> >
> >
> >