Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default Userform Can't seem to work right

Hello,
have userform with two Option buttons and two command
buttons one for OK and Cancel.
Here's the code for the OK button:
Private Sub CommandButton1_Click()

' Dim MyButtons As Object

If OptionButton1.Value = True Then
Sheets("ZSDQT002LATEST").PrintPreview
UserForm1.Hide
ElseIf OptionButton2.Value = True Then
Application.GetSaveAsFilename
End If
End Sub
When I select the Print Preview option and click OK it
goes to Print Preview, but the Userform doesn't close and
can't close it and excel gets stuck. So I have to End
program. Does anyone have idea why this is happening.
Thanks,
Juan
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default Userform Can't seem to work right

Hello Chris,
its still doing the same. I do go to the Preview, but the
userform still shows and it get stuck. I can't do
anything. Can't evern close it manually or can't even use
excel. So I have to terminate.
Not sure why is doing it. When I select the other option
to save, I do get it to work fine. Doesn't get stuck. So
not sure why when I want to preview and stay here it get
stuck.

Any other advise?

Thanks,

juan
-----Original Message-----
try this:
Private Sub CommandButton1_Click()
If OptionButton1.Value = True Then
Sheets("ZSDQT002LATEST").PrintPreview
Unload Me
exit sub
ElseIf OptionButton2.Value = True Then
Application.GetSaveAsFilename
End If

End Sub


----- juan wrote: -----

Hello,
have userform with two Option buttons and two

command
buttons one for OK and Cancel.
Here's the code for the OK button:
Private Sub CommandButton1_Click()

' Dim MyButtons As Object

If OptionButton1.Value = True Then
Sheets("ZSDQT002LATEST").PrintPreview
UserForm1.Hide
ElseIf OptionButton2.Value = True Then
Application.GetSaveAsFilename
End If
End Sub
When I select the Print Preview option and click OK

it
goes to Print Preview, but the Userform doesn't

close and
can't close it and excel gets stuck. So I have to

End
program. Does anyone have idea why this is

happening.
Thanks,
Juan

.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Userform Can't seem to work right

Private Sub CommandButton1_Click()
Dim fName as Variant
' Dim MyButtons As Object
userform1.hide
If OptionButton1.Value = True Then
Sheets("ZSDQT002LATEST").PrintPreview
ElseIf OptionButton2.Value = True Then

fname =Application.GetSaveAsFilename
if fname < false then
ThisWorkbook.SaveAs fName
end if

End If
End Sub

You code stops on the printpreview command until you close printpreview, so
your code never gets to the Userform1.Hide command until print preview is
closed. Changing the order as shown should solve the problem.

Also, doing Application.GetSaveAsFilename does not save the file. It just
returns the name selected by the user. You then have to execute SaveAs with
the returned value to actually save the file under that name.



--
Regards,
Tom Ogilvy


"Juan" wrote in message
...
Hello Chris,
its still doing the same. I do go to the Preview, but the
userform still shows and it get stuck. I can't do
anything. Can't evern close it manually or can't even use
excel. So I have to terminate.
Not sure why is doing it. When I select the other option
to save, I do get it to work fine. Doesn't get stuck. So
not sure why when I want to preview and stay here it get
stuck.

Any other advise?

Thanks,

juan
-----Original Message-----
try this:
Private Sub CommandButton1_Click()
If OptionButton1.Value = True Then
Sheets("ZSDQT002LATEST").PrintPreview
Unload Me
exit sub
ElseIf OptionButton2.Value = True Then
Application.GetSaveAsFilename
End If

End Sub


----- juan wrote: -----

Hello,
have userform with two Option buttons and two

command
buttons one for OK and Cancel.
Here's the code for the OK button:
Private Sub CommandButton1_Click()

' Dim MyButtons As Object

If OptionButton1.Value = True Then
Sheets("ZSDQT002LATEST").PrintPreview
UserForm1.Hide
ElseIf OptionButton2.Value = True Then
Application.GetSaveAsFilename
End If
End Sub
When I select the Print Preview option and click OK

it
goes to Print Preview, but the Userform doesn't

close and
can't close it and excel gets stuck. So I have to

End
program. Does anyone have idea why this is

happening.
Thanks,
Juan

.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default Userform Can't seem to work right

Hello Tom
thanks alot this works. Appreciate the help.

Juan
-----Original Message-----
Private Sub CommandButton1_Click()
Dim fName as Variant
' Dim MyButtons As Object
userform1.hide
If OptionButton1.Value = True Then
Sheets("ZSDQT002LATEST").PrintPreview
ElseIf OptionButton2.Value = True Then

fname =Application.GetSaveAsFilename
if fname < false then
ThisWorkbook.SaveAs fName
end if

End If
End Sub

You code stops on the printpreview command until you

close printpreview, so
your code never gets to the Userform1.Hide command until

print preview is
closed. Changing the order as shown should solve the

problem.

Also, doing Application.GetSaveAsFilename does not save

the file. It just
returns the name selected by the user. You then have to

execute SaveAs with
the returned value to actually save the file under that

name.



--
Regards,
Tom Ogilvy


"Juan" wrote in message
...
Hello Chris,
its still doing the same. I do go to the Preview, but

the
userform still shows and it get stuck. I can't do
anything. Can't evern close it manually or can't even

use
excel. So I have to terminate.
Not sure why is doing it. When I select the other option
to save, I do get it to work fine. Doesn't get stuck. So
not sure why when I want to preview and stay here it get
stuck.

Any other advise?

Thanks,

juan
-----Original Message-----
try this:
Private Sub CommandButton1_Click()
If OptionButton1.Value = True Then
Sheets("ZSDQT002LATEST").PrintPreview
Unload Me
exit sub
ElseIf OptionButton2.Value = True Then
Application.GetSaveAsFilename
End If

End Sub


----- juan wrote: -----

Hello,
have userform with two Option buttons and two

command
buttons one for OK and Cancel.
Here's the code for the OK button:
Private Sub CommandButton1_Click()

' Dim MyButtons As Object

If OptionButton1.Value = True Then
Sheets("ZSDQT002LATEST").PrintPreview
UserForm1.Hide
ElseIf OptionButton2.Value = True Then
Application.GetSaveAsFilename
End If
End Sub
When I select the Print Preview option and click

OK
it
goes to Print Preview, but the Userform doesn't

close and
can't close it and excel gets stuck. So I have to

End
program. Does anyone have idea why this is

happening.
Thanks,
Juan

.



.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to make userform work publically with hidden sheets? Zigball Excel Discussion (Misc queries) 7 October 25th 06 03:30 PM
How to make userform work publically with hidden sheets? Zigball Excel Worksheet Functions 7 October 25th 06 03:30 PM
How to have a userform displayed and be able to work in a different spreadsheet Valeria[_2_] Excel Programming 1 January 19th 04 05:22 PM
Label Caption Just Wont Work on UserForm K[_3_] Excel Programming 2 September 15th 03 03:29 PM
Userforms and autofilters - Autofilters don't seen to work with userform No Name Excel Programming 3 August 28th 03 05:42 PM


All times are GMT +1. The time now is 03:02 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"