Value of Public Variable Not Being Passed

Ark68

Well-known Member
Joined
Mar 23, 2004
Messages
4,564
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
I have oBP declared publically as an object.

This code sets it ..
Rich (BB code):
Private Sub tglb_cue_gm_Click()
    With Me
        Set oBP = .tglb_cue_gm
        sRPT = "CUE-GM.docx"
        button_check ' oBP, sRPT
    End With
End Sub

But when it reaches this code to use is it, I get an error (red line) "Object variable or WIth Block variable not set." It appears to be caused because oBP is empty.

Rich (BB code):
Sub button_check()  '(ByVal oBP As Object, sRPT As String)

'oBP = userform toggle button name (from toggle button click event)
'sRPT = report (.docx) filename (from toggle button click event)

    If bpb = 0 Then 'bypass if bypass flag = 1
        With uf4_works 'the userform
            With oBP
                'this allows a previouly created report to be viewed.
                If .BackColor = RGB(0, 153, 211) And .Value = True Then
                    If DocOpen(sRPT) = False Then
                        Set WordApp = CreateObject("word.Application")
                        WordApp.Documents.Open path_name & sRPT
                        WordApp.Visible = True
                        Set WordApp = Nothing
                        .Value = True
                    End If
    ...

Any thought on what needs to be corrected?
 
Last edited:
Glad you sorted it & thanks for the feedback.
 
Upvote 0

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.

Forum statistics

Threads
1,223,236
Messages
6,170,915
Members
452,366
Latest member
TePunaBloke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top