problems with dialogs

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello
I'm using a dialog to give easier access to macros.
But when running a macro after the dialog (still open) I got a error msg if
I tried to open anoter dialog like (printer dialog).
How to solve this .? I have tried to use sendkeys (% F4) to close the first
one but without success to close it like this.

Thanks.
 
What dialog are you initially running for easier access to macros?

--

HTH

RP
(remove nothere from the email address if mailing direct)
 
a custom dialog created under Excel (insert / MS 5.0 Excel Dialog)

Thannks for your help.
 
I feared that might be what you were using. I don't know why you get the
problem since it is many years since I have used the MS 5.0 Excel Dialog.
Could you not create a use3rform for you macro initiation rather than this
old dialog?

--

HTH

RP
(remove nothere from the email address if mailing direct)
 
insert / MS 5.0 Excel Dialog inserts a dialogsheet. The code you post all
the time (and modify all the time) is based on the dialogsheet. What do you
interpret him to be talking about?
 
I don't think you can run an Application.Dialog at same time as your Dialog
form. Try OnTime method:

'// in a normal module
'// from Forms toolbar, put a button on Dialog1 and
'// assign it to BtnPrint

Public Arg
Sub Main()
ThisWorkbook.DialogSheets("Dialog1").Show
End Sub

Sub ReShowMyDialog(Optional n As Long)
'whatever initialization code
If n = 123 Then
MsgBox "User cancelled print dialog"
'If IsArray(Arg) Then Erase Arg
End If
Main
End Sub

Sub BtnPrint()
Dim j As Long

Arg = Array(2, 1, 2) '(Page(s), From 1, To 2)
j = 123

Application.OnTime Now, " 'PrintShow " & j & " ' "
ThisWorkbook.DialogSheets("Dialog1").Hide
End Sub

Sub PrintShow(Optional num As Long)
Dim x
x = Application.Dialogs(xlDialogPrint).Show(Arg(0), Arg(1), Arg(2))
If x = False And num = 123 Then
ReShowMyDialog num
Else: Erase Arg
End If
End Sub

Regards,
Peter T
 

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

Back
Top