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 / November 2006

Tip: Looking for answers? Try searching our database.

For...Next Satement with a UserForm

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Charles - 08 Nov 2006 13:16 GMT
I have a UserForm which is used to update a document and print two copies.
The user enters the number of docs to complete in a TexBox TxtCnt.

The For.. Next Statement works but control does not return to the UserForm
after printing. How do i do that?

This is a simplified version of the code (I have removed a lot of repetitive
lines):

Private Sub cmdOK_Click()
Dim strReason As String
Dim strType As String
Dim i As Integer
For i = 1 To TxtCnt.Value
   
   If optReason1 = True Then strReason = "Actual Exit"
   If optType1 = True Then strType = "Leaving Service"
   
   Application.ScreenUpdating = False
     
   UpdateBookmark "bmkID", txtID.Value
   UpdateBookmark "bmkSur", txtSur.Value
 
   Application.ScreenUpdating = True
   ActiveDocument.PrintOut Copies:=2
 
   optReason1.Value = True
   optType1.Value = True
   txtID.Value = Null
   txtSur.Value = Null

   Application.ScreenUpdating = True

Next i
   
End Sub

Thanks for any help you can offer.
Jean-Guy Marcil - 09 Nov 2006 20:20 GMT
Charles was telling us:
Charles nous racontait que :

> I have a UserForm which is used to update a document and print two
> copies. The user enters the number of docs to complete in a TexBox
[quoted text clipped - 35 lines]
>
> Thanks for any help you can offer.

You could  hide it before launching the procedure and the Show it again
after.

Private Sub cmdOK_Click()
Dim strReason As String
Dim strType As String
Dim i As Integer

Me.Hide

For i = 1 To TxtCnt.Value
   'Your code...
Next i

Me.Show

End Sub

Does that help?

Signature

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

Charles - 10 Nov 2006 08:51 GMT
Hi Jean-Guy

Merci! As usal, a simple solution.

Regards

Charles

> Charles was telling us:
> Charles nous racontait que :
[quoted text clipped - 58 lines]
>
> Does that help?

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.