If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
problem in VB codes
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. |
#2
|
|||
|
|||
problem in VB codes
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. |
#3
|
|||
|
|||
problem in VB codes
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. |
#4
|
|||
|
|||
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. |
#5
|
|||
|
|||
problem in VB codes
no, still ,I have the problem!! the change in optionbuttons doesn't show up
in the prints.how the "preview" can help me???!!!!it makes the procedure manual!! thanx anyway. "Joel" wrote: 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. |
#6
|
|||
|
|||
problem in VB codes
I tried adding some DoEvents. And it didn't help.
I tried toggling application.screenupdating off, then on. And it didn't help. I tried adding application.wait (for a second). And it didn't help. I tried adding minimizing the activewindow, then restoring it. And it didn't help. But this seemed to work ok for me. Actually, I didn't test on paper. I only tested using print preview. But the others failed with that. This one worked ok. Option Explicit Private Sub CommandButton11_Click() Me.Range("G13:I32").Font.ColorIndex = xlAutomatic Me.PrintOut preview:=True, Copies:=1, Collate:=True If Me.OptionButton1.Value = True Then Me.OptionButton2.Value = True Else Me.OptionButton1.Value = True End If Application.OnTime earliesttime:=Now + TimeSerial(0, 0, 1), _ procedu="'" & ThisWorkbook.Name & "'!" & Me.CodeName & ".WaitABit" End Sub Private Sub WaitABit() Me.Range("G13:I32").Font.ColorIndex = 2 Me.PrintOut preview:=True, Copies:=1, Collate:=True End Sub (The WaitABit code is in the same worksheet module.) 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. -- Dave Peterson |
#7
|
|||
|
|||
problem in VB codes
Did/has anyone tried to .Repaint the form/control before the print?
I know, I'm lazy AND hate burning paper, so I didn't try it myself, but I've used that in the past to get 'instant' updates to the appearance of a control. "Dave Peterson" wrote: I tried adding some DoEvents. And it didn't help. I tried toggling application.screenupdating off, then on. And it didn't help. I tried adding application.wait (for a second). And it didn't help. I tried adding minimizing the activewindow, then restoring it. And it didn't help. But this seemed to work ok for me. Actually, I didn't test on paper. I only tested using print preview. But the others failed with that. This one worked ok. Option Explicit Private Sub CommandButton11_Click() Me.Range("G13:I32").Font.ColorIndex = xlAutomatic Me.PrintOut preview:=True, Copies:=1, Collate:=True If Me.OptionButton1.Value = True Then Me.OptionButton2.Value = True Else Me.OptionButton1.Value = True End If Application.OnTime earliesttime:=Now + TimeSerial(0, 0, 1), _ procedu="'" & ThisWorkbook.Name & "'!" & Me.CodeName & ".WaitABit" End Sub Private Sub WaitABit() Me.Range("G13:I32").Font.ColorIndex = 2 Me.PrintOut preview:=True, Copies:=1, Collate:=True End Sub (The WaitABit code is in the same worksheet module.) 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. -- Dave Peterson |
#8
|
|||
|
|||
problem in VB codes
Oops, just a little pink in the face: .Repaint is only available for
UserForm, not individual controls, so that may have been a useless thought. "Dave Peterson" wrote: I tried adding some DoEvents. And it didn't help. I tried toggling application.screenupdating off, then on. And it didn't help. I tried adding application.wait (for a second). And it didn't help. I tried adding minimizing the activewindow, then restoring it. And it didn't help. But this seemed to work ok for me. Actually, I didn't test on paper. I only tested using print preview. But the others failed with that. This one worked ok. Option Explicit Private Sub CommandButton11_Click() Me.Range("G13:I32").Font.ColorIndex = xlAutomatic Me.PrintOut preview:=True, Copies:=1, Collate:=True If Me.OptionButton1.Value = True Then Me.OptionButton2.Value = True Else Me.OptionButton1.Value = True End If Application.OnTime earliesttime:=Now + TimeSerial(0, 0, 1), _ procedu="'" & ThisWorkbook.Name & "'!" & Me.CodeName & ".WaitABit" End Sub Private Sub WaitABit() Me.Range("G13:I32").Font.ColorIndex = 2 Me.PrintOut preview:=True, Copies:=1, Collate:=True End Sub (The WaitABit code is in the same worksheet module.) 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. -- Dave Peterson |
#9
|
|||
|
|||
problem in VB codes
I don't think its the control, I think the problem is with the window. but
you gave me a good idea that seems to work. If you activate the window between the prints it solves the problem. Activating the window does a repaint. 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 ActiveWindow.Activate Range("G13:I32").Select Selection.Font.ColorIndex = 2 ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True End Sub "JLatham" wrote: Oops, just a little pink in the face: .Repaint is only available for UserForm, not individual controls, so that may have been a useless thought. "Dave Peterson" wrote: I tried adding some DoEvents. And it didn't help. I tried toggling application.screenupdating off, then on. And it didn't help. I tried adding application.wait (for a second). And it didn't help. I tried adding minimizing the activewindow, then restoring it. And it didn't help. But this seemed to work ok for me. Actually, I didn't test on paper. I only tested using print preview. But the others failed with that. This one worked ok. Option Explicit Private Sub CommandButton11_Click() Me.Range("G13:I32").Font.ColorIndex = xlAutomatic Me.PrintOut preview:=True, Copies:=1, Collate:=True If Me.OptionButton1.Value = True Then Me.OptionButton2.Value = True Else Me.OptionButton1.Value = True End If Application.OnTime earliesttime:=Now + TimeSerial(0, 0, 1), _ procedu="'" & ThisWorkbook.Name & "'!" & Me.CodeName & ".WaitABit" End Sub Private Sub WaitABit() Me.Range("G13:I32").Font.ColorIndex = 2 Me.PrintOut preview:=True, Copies:=1, Collate:=True End Sub (The WaitABit code is in the same worksheet module.) 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. -- Dave Peterson |
#10
|
|||
|
|||
problem in VB codes
I also assumed that these were controls from the control toolbox toolbar placed
on the worksheet. JLatham wrote: Did/has anyone tried to .Repaint the form/control before the print? I know, I'm lazy AND hate burning paper, so I didn't try it myself, but I've used that in the past to get 'instant' updates to the appearance of a control. "Dave Peterson" wrote: I tried adding some DoEvents. And it didn't help. I tried toggling application.screenupdating off, then on. And it didn't help. I tried adding application.wait (for a second). And it didn't help. I tried adding minimizing the activewindow, then restoring it. And it didn't help. But this seemed to work ok for me. Actually, I didn't test on paper. I only tested using print preview. But the others failed with that. This one worked ok. Option Explicit Private Sub CommandButton11_Click() Me.Range("G13:I32").Font.ColorIndex = xlAutomatic Me.PrintOut preview:=True, Copies:=1, Collate:=True If Me.OptionButton1.Value = True Then Me.OptionButton2.Value = True Else Me.OptionButton1.Value = True End If Application.OnTime earliesttime:=Now + TimeSerial(0, 0, 1), _ procedu="'" & ThisWorkbook.Name & "'!" & Me.CodeName & ".WaitABit" End Sub Private Sub WaitABit() Me.Range("G13:I32").Font.ColorIndex = 2 Me.PrintOut preview:=True, Copies:=1, Collate:=True End Sub (The WaitABit code is in the same worksheet module.) 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. -- Dave Peterson -- Dave Peterson |
Thread Tools | |
Display Modes | |
|
|