Run time error 91 - Object Variable or With block variable not set

Pauljj

Well-known Member
Joined
Mar 28, 2004
Messages
2,047
Hello all,

I am opening up a workbook which, the workbook module has not changed but all of a sudden I am getting above error message, this happens upon opening. I can click end and it gives me no option to debug

The open code is as follows

Code:
Private Sub Workbook_Open()


Application.ScreenUpdating = False

Application.ErrorCheckingOptions.BackgroundChecking = False

Application.Calculation = xlCalculationManual

Application.DisplayAlerts = True

Worksheets("Restriction").Range("a$1") = 1

Worksheets("Restriction").Range("a$17") = "Incite Version 14 is opening"

Worksheets("Restriction").Calculate

    With Application
        .CalculateBeforeSave = True
    End With

Sheets("Staff Data").Visible = True
Sheets("March").Visible = True
Sheets("April").Visible = True
Sheets("May").Visible = True
Sheets("June").Visible = True
Sheets("July").Visible = True
Sheets("August").Visible = True
Sheets("September").Visible = True
Sheets("October").Visible = True
Sheets("November").Visible = True
Sheets("December").Visible = True
Sheets("January").Visible = True
Sheets("February").Visible = True
Sheets("Charts").Visible = True
Sheets("Data").Visible = True
Sheets("Stat Data").Visible = True

Sheets("Restriction").Visible = xlVeryHidden

ThisWorkbook.Saved = True


If ActiveWorkbook.ReadOnly = True Then

Exit Sub

Else



If Environ("username") <> "Paulha" And Environ("username") <> "paulha" And Environ("username") <> "Paul Hailes" Then ActiveWorkbook.ChangeFileAccess xlReadOnly


End If

Application.ScreenUpdating = True


End Sub


Private Sub Workbook_BeforeClose(cancel As Boolean)

If ActiveWorkbook.ReadOnly = True Then


 ThisWorkbook.Saved = True
 
 Else
 
Worksheets("Restriction").Range("a$17") = "Incite Version 14 is closing"

Worksheets("Restriction").Calculate

Sheets("Restriction").Visible = True

Sheets("Staff Data").Visible = xlVeryHidden
Sheets("March").Visible = xlVeryHidden
Sheets("April").Visible = xlVeryHidden
Sheets("May").Visible = xlVeryHidden
Sheets("June").Visible = xlVeryHidden
Sheets("July").Visible = xlVeryHidden
Sheets("August").Visible = xlVeryHidden
Sheets("September").Visible = xlVeryHidden
Sheets("October").Visible = xlVeryHidden
Sheets("November").Visible = xlVeryHidden
Sheets("December").Visible = xlVeryHidden
Sheets("January").Visible = xlVeryHidden
Sheets("February").Visible = xlVeryHidden
Sheets("Charts").Visible = xlVeryHidden
Sheets("Data").Visible = xlVeryHidden
Sheets("Stat Data").Visible = xlVeryHidden



    With Application
        .CalculateBeforeSave = False
    End With

Worksheets("Restriction").Range("$a$1") = 0


Application.DisplayAlerts = False


ActiveWorkbook.Save

End If

   
End Sub

The application.display alerts and subsequent code do not action. I can tell this because of the screen flicker I get and the workbook does not open on the correct sheet

I do have a code set in the closing of the workbook which I can send it that helps

I have one PC where I have not actioned Microsofr user updates....when I open this workbook on that machine, I don't get the problem. I only get the error on the machine I did do the updates on

Any ideas please ??


Thanks
Paul
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.

Forum statistics

Threads
1,216,099
Messages
6,128,822
Members
449,469
Latest member
Kingwi11y

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