Value of Public Variable Not Being Passed

Ark68

Well-known Member
Joined
Mar 23, 2004
Messages
4,570
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

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).

Forum statistics

Threads
1,223,904
Messages
6,175,295
Members
452,633
Latest member
DougMo

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