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 / December 2004

Tip: Looking for answers? Try searching our database.

Inbuilt Dialogs Handling

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ren? Probst - 10 Dec 2004 12:40 GMT
Hi:

WD2002

When I use a code like the following and the user enters an "a" for
the field "copies" the Dialog is redisplayed...

... well done!.

After the dialog is redisplayed the user is correcting his error by
entering a "3" and clicks "Ok"...

... *sniff my code stacks now on the display-Method and a run time
error is indicated.

I have tested a lot of work arounds (on error resume next, etc.) but I
am not successful in controlling this process flow properly.

PS: If I use an error routine, then the feedback of the display-Method
is neither -1 nor 0, but *empty*.

Your help is highly appreciated.

Kind regards
René Probst


Sub Test()
 With Dialogs(wdDialogFilePrint)
     If .Display = -1 Then
         If .NumCopies > 1 Then
             MsgBox "You cannot print more than 1 copy."
         Else
             .Execute
         End If
     End If
 End With
End Sub
Helmut Weber - 10 Dec 2004 22:39 GMT
Hi René,
I wonder, whether this will help, but anyway,
what I've found out is, that
after input of 1 character that isn't a digit,
.numcopies will return the preset value.
So if you preset .numcopies by 1,
after an input of a, [ok], 2,
.numcopies will still return 1.
Which means, that, if a user types "a",
corrects it to "2", 1 copy will be printed.
Otherwise, you may preset .numcopies by "".
Which means, that a user will have to enter 1,
though she/he has no other choice.
Auch nicht das Gelbe vom Ei!!!
(Not the intention of the inventor).

One should translate Your site into English!
Non German speakers miss a lot!

At least, the error message can be avoided.
The code is only a scribble.

Sub Test()
Dim r As Variant
Dim n As Variant
 With Dialogs(wdDialogFilePrint)
start:
 .numcopies = "1"
     On Error Resume Next
     r = .Display
     n = .numcopies
     If n = "" Then
        MsgBox "try again"
        GoTo start
     End If
     If n > 1 Then
        MsgBox "You can print only 1 copy."
        GoTo start
     End If
 End With
End Sub

Greetings from Bavaria, Germany
Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word XP, Win 98
http://word.mvps.org/

>Hi:
>
[quoted text clipped - 33 lines]
>  End With
>End Sub

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.