ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Run Time Error (https://www.excelbanter.com/excel-programming/303689-run-time-error.html)

Markus

Run Time Error
 
I have a file that when macros are enabled provides me
with a "Run Time Error 5". When I debug it takes me to a
line of code that reads
Set wb = Workbooks.Open("U:\Quality Team\QA MAIN\Analysis
and ReportsLG KL GN\Corporate Excel Reports\QARP2004
\ProgramReports\PG1Rep2004.xls")

The path is correct.

Here is the complete sub

Private Sub Workbook_Open()

Dim wb As Workbook
Dim lngColor As Long
lngColor = RGB(221, 221, 221)
ActiveWorkbook.Colors(16) = lngColor
Sheets("SR").Select
Application.Goto Reference:=Worksheets("Front").Range
("A1"), Scroll:=True
Application.CommandBars("Formatting").Visible = False
Application.CommandBars("Borders").Visible = False
Application.CommandBars("Chart").Visible = False
Application.CommandBars("Control ToolBox").Visible = False
Application.CommandBars("Drawing").Visible = False
Application.CommandBars("Clipboard").Visible = False
Application.CommandBars("External Data").Visible = False
Application.CommandBars("Forms").Visible = False

Application.CommandBars("Picture").Visible = False
Application.CommandBars("PivotTable").Visible = False

Application.CommandBars("Reviewing").Visible = False

Application.CommandBars("Visual Basic").Visible = False

Application.CommandBars("Web").Visible = False
Application.CommandBars("WordArt").Visible = False
Application.CommandBars("Standard").Visible = True

Application.ScreenUpdating = False ' turn off the screen
updating
Set wb = Workbooks.Open("U:\Quality Team\QA MAIN\Analysis
and ReportsLG KL GN\Corporate Excel Reports\QARP2004
\ProgramReports\PG1Rep2004.xls")
With ThisWorkbook.Worksheets("Front")
..Range("A8").Value = wbz.Worksheets("Objectives").Range
("F2").Value

wb.Close False
Application.ScreenUpdating = True ' turn on the screen
updating

End With
End Sub


All times are GMT +1. The time now is 06:43 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com