Inbuilt Dialogs Handling

R

Ren? Probst

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
 
H

Helmut Weber

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/
 

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

Similar Threads


Top