Ark68
Well-known Member
- Joined
- Mar 23, 2004
- Messages
- 4,533
- Office Version
- 365
- 2016
- Platform
- Windows
Hi folks,
I'm at a point in my VBA application where a hurdle is preventing me from moving forward.
I have a worksheet that provides an interface for the user to click on radio "style" shapes to select which report or combination of multiple reports to print. The radio buttons provided in the form controls are too tiny and don't provide the flexibility I am looking for, so I've substituted them with macro enabled shapes.
There are 6 individual reports (CUEDR, CUEDT, CUEFR, CUEFT, CUECR and CUECT). When the user clicks the shape (rtarget), the macro is called which calls a routine. The routine checks the appropriateness of the report request (record has to have at least 1 record to be considered appropriate), shades it, and puts the report name in the print cue.
There is also a 7th clickable shape option. CUEALL (rtarget), when clicked allows the user to choose all 6 records together. The way I have it working now (and I know it's not glamorous or efficient) , if the CUEALL procedure calls each one of the reports individual procedures to execute.
Herein lay the problem. When CUEALL is selected, rtarget = CUEALL. Since the individual reports rely on rtarget= to their respective shapes for shading, the code is incomplete. The intended result is for all individual shapes be shaded (when appropriate) and the CUEALL shape. But with this code ... when all is said and done, only the CUEALL shape gets shaded, and only CUEALL is placed in the cue (when it should be one or more of either CUEDR, CUEDT, CUEFR, CUEFT, CUECR and CUECT)
What do I need to do to get the individual shapes to shade and the individual report names put in the cue when a group shape is selected?
I'm at a point in my VBA application where a hurdle is preventing me from moving forward.
I have a worksheet that provides an interface for the user to click on radio "style" shapes to select which report or combination of multiple reports to print. The radio buttons provided in the form controls are too tiny and don't provide the flexibility I am looking for, so I've substituted them with macro enabled shapes.
There are 6 individual reports (CUEDR, CUEDT, CUEFR, CUEFT, CUECR and CUECT). When the user clicks the shape (rtarget), the macro is called which calls a routine. The routine checks the appropriateness of the report request (record has to have at least 1 record to be considered appropriate), shades it, and puts the report name in the print cue.
There is also a 7th clickable shape option. CUEALL (rtarget), when clicked allows the user to choose all 6 records together. The way I have it working now (and I know it's not glamorous or efficient) , if the CUEALL procedure calls each one of the reports individual procedures to execute.
Herein lay the problem. When CUEALL is selected, rtarget = CUEALL. Since the individual reports rely on rtarget= to their respective shapes for shading, the code is incomplete. The intended result is for all individual shapes be shaded (when appropriate) and the CUEALL shape. But with this code ... when all is said and done, only the CUEALL shape gets shaded, and only CUEALL is placed in the cue (when it should be one or more of either CUEDR, CUEDT, CUEFR, CUEFT, CUECR and CUECT)
What do I need to do to get the individual shapes to shade and the individual report names put in the cue when a group shape is selected?
Code:
Sub toggle()
Dim wshwo As Worksheet
Dim wshvar As Worksheet
Dim rtarget As Variant
Dim nextrow As Integer
Dim p1 As Variant
Set wshvar = Worksheets("varhold")
Set wshwo = Worksheets("Workorders")
Set rtarget = wshwo.Shapes(Application.Caller)
nextrow = wshvar.Cells(Rows.Count, "T").End(xlUp).Row + 1
With wshwo
If rtarget.Name = "CUEDR" Then
Call rtCUEDR
ElseIf rtarget.Name = "CUEDT" Then
Call rtCUEDT
ElseIf rtarget.Name = "CUEFR" Then
Call rtCUEFR
ElseIf rtarget.Name = "CUEFT" Then
Call rtCUEFT
ElseIf rtarget.Name = "CUECR" Then
Call rtCUECR
ElseIf rtarget.Name = "CUEFT" Then
Call rtCUECT
Else 'rtarget.name="CUEALL"
Call rtCUEDR
Call rtCUEDT
Call rtCUEFR
Call rtCUEFT
Call rtCUECR
Call rtCUECT
End If
End With
End Sub
Code:
Sub shade_me()
Dim wshwo As Worksheet
Dim wshvar As Worksheet
Dim rtarget As Variant
Dim nextrow As Integer
Dim p1 As Variant
Set wshvar = Worksheets("varhold")
Set wshwo = Worksheets("Workorders")
Set rtarget = wshwo.Shapes(Application.Caller)
nextrow = wshvar.Cells(Rows.Count, "T").End(xlUp).Row + 1
If rtarget.Fill.ForeColor.RGB = RGB(255, 255, 255) Then 'OFF to ON
rtarget.Fill.ForeColor.RGB = RGB(255, 0, 0)
wshvar.Range("T" & nextrow) = rtarget.Name
Else
rtarget.Fill.ForeColor.RGB = RGB(255, 255, 255) 'ON to OFF
p1 = wshvar.Range("T3:T500").Find(What:=rtarget.Name).Address
wshvar.Cells.Range(p1).Delete xlUp
End If
End Sub
Code:
Sub rtCUEDR()
If ActiveSheet.Range("E10").Value = 0 Then
MsgBox "Skip CUEDR"
Exit Sub
Else
Call shade_me
End If
End Sub
Sub rtCUEDT()
If ActiveSheet.Range("F10").Value = 0 Then
MsgBox "Skip CUEDT"
Exit Sub
Else
Call shade_me
End If
End Sub
Sub rtCUEFR()
If ActiveSheet.Range("G10").Value = 0 Then
MsgBox "Skip CUEFR"
Exit Sub
Else
Call shade_me
End If
End Sub
Sub rtCUEFT()
If ActiveSheet.Range("H10").Value = 0 Then
MsgBox "Skip CUEFT"
Exit Sub
Else
Call shade_me
End If
End Sub
Sub rtCUECR()
If ActiveSheet.Range("I10").Value = 0 Then
MsgBox "Skip CUECR"
Exit Sub
Else
Call shade_me
End If
End Sub
Sub rtCUECT()
If ActiveSheet.Range("J10").Value = 0 Then
MsgBox "Skip CUECT"
Exit Sub
Else
Call shade_me
End If
End Sub