View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.misc
joel joel is offline
external usenet poster
 
Posts: 9,101
Default problem in VB codes

I was able to repeat the problem. Found a fix, you may not like it. Add a
Preview to the print

ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True , Preview:=True

"peyman" wrote:

No Joel, it toggles.it's weird! in the worksheet it toggles but in print
no!!!!!!!!!!!

"Joel" wrote:

Your code has no toggle. You are setting the options buttons to true none
are being set to false.

I think you want to add a group box around the two controls so they toggle.
From the excel spreadsheet menu - View - Toolbars - Forms. Put a group box
around the two buttons so they will automatically toggle.

"peyman" wrote:

hi,
I have a very simple code ,but I don't know why it doesn't work.

Private Sub CommandButton11_Click()
Range("G13:I32").Select
Selection.Font.ColorIndex = xlAutomatic
Range("B7").Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
If ActiveSheet.OptionButton1.Value = True Then
ActiveSheet.OptionButton2.Value = True
Else
ActiveSheet.OptionButton1.Value = True
End If
Range("G13:I32").Select
Selection.Font.ColorIndex = 2
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
End Sub

the problem is when I run the program, the optionbutton toggle is not
showing in the second print?!!
Any help?thank you.