I have a spreadsheet that has an option button group where you can select 2 options. When I open the file I can select either option and this works perfectly. After I run code to export out the sheets to pdf when I hover over the options buttons the cursor shows a black circle with a slash through it. Is there a piece of code that is causing this issue or does anyone know how to resolve?
The cursor looks as shown here:
The code that I am running is the following:
Any help is appreciated. Thank you.
The cursor looks as shown here:
The code that I am running is the following:
VBA Code:
Sub PrintSheet1()
Dim wsA As Worksheet
Dim wsB As Worksheet
Dim valueInKS1 As Integer
Dim sName As String
Dim FileSelected As String
On Error Resume Next
sName = Left(ActiveWorkbook.Name, InStr(1, ActiveWorkbook.Name, ".") - 1)
' Turn off screen updating and automatic calculations for efficiency
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
' Set worksheets (adjust sheet names if needed)
Set wsA = Worksheets("Bioretention")
Set wsB = Worksheets("Storage-Discharge")
' Get value from cell KS1 on the active sheet (assuming Bioretention)
valueInKS1 = wsA.Range("KS1").Value
Select Case valueInKS1
Case 1
' Print only worksheet A directly using Sheets collection
FileSelected = Application.GetSaveAsFilename(InitialFileName:=sName, _
FileFilter:="PDF Files (*.pdf), *.pdf", _
Title:="Save PDF as")
If Not FileSelected <> "False" Then
Exit Sub
End If
Sheets(Array("Bioretention")).Select
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, _
Filename:=FileSelected, _
OpenAfterPublish:=True
Case 2
' Print both worksheets A and B directly using Sheets collection
wsB.Visible = True
FileSelected = Application.GetSaveAsFilename(InitialFileName:=sName, _
FileFilter:="PDF Files (*.pdf), *.pdf", _
Title:="Save PDF as")
If Not FileSelected <> "False" Then
Exit Sub
End If
Sheets(Array("Bioretention", "Storage-Discharge")).Select
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, _
Filename:=FileSelected, _
OpenAfterPublish:=True
wsB.Visible = False
Case Else
' Handle other cases (optional)
MsgBox "Invalid value. No sheets printed. Please select Preliminary or Final Design"
End Select
' Turn screen updating and automatic calculations back on
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
wsA.Visible = True
End Sub
Any help is appreciated. Thank you.