Help debbuging - I have checked the path, files names, etc. any help is appreciated.

Copper Contributor

Private Sub Workbook_Activate()

End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)

Workbooks("DONT DELETE.xls").Close SaveChanges:=False
Kill "G:\Training Unit\Cadet Training\Unit Folder\Instructors\Class Material\Departments\Testing\DONT DELETE.xls"

'Workbooks("DONT DELETE.xls").Close SaveChanges:=False
'Kill "E:\DONT DELETE.xls"
End Sub

Private Sub Workbook_Open()
'MsgBox ("Hello")
Worksheets("FrontPage").Cells(1, 3).Value = ActiveWorkbook.name

Worksheets("FrontPage").TopComboBox.List = Array("ALL CADETS", "Blue", "Green", "Gray")
Worksheets("FrontPage").TopComboBox.Value = "ALL CADETS"
Worksheets("FrontPage").ComboBoxData.List = Array("Scenarios Overview", "Active Scenarios", "Completed Scenarios", "Current Status", "Totals")
Worksheets("FrontPage").ComboBoxData.Value = "Scenarios Overview"
' LOW PRIORITY: remove the list of cadets on front page
' and replace with a pull from the list on activation


Worksheets("IndividualPage").IndPageCBOX.List = Array("EVALUATOR", "CADET", "SCENARIO", "DATE")

Workbooks.Add
ActiveWorkbook.SaveAs "G:\Training Unit\Cadet Training\Unit Folder\Instructors\Class Material\Departments\Testing\DONT DELETE.xls"
Workbooks.Open Filename:="G:\Training Unit\Cadet Training\Unit Folder\Instructors\Class Material\Departments\Testing\DONT DELETE.xls"
stuff

'Workbooks.Add
'ActiveWorkbook.SaveAs "E:\DONT DELETE.xls"
'Workbooks.Open Filename:="E:\DONT DELETE.xls"
'Stuff

End Sub

Private Sub stuff()
Dim wbBook As Workbook
Dim wsSheet As Worksheet

Set wbBook = Workbooks("DONT DELETE.xls")
Set wsSheet = wbBook.Worksheets("Sheet1")

Dim stuff As String
stuff = Worksheets("FrontPage").Cells(1, 3).Value

wsSheet.Range("A1").Value = "='[" + stuff + "]Dashboard'!$A$1"
wsSheet.Range("A2").Value = "='[" + stuff + "]Dashboard'!$A$2"
wsSheet.Range("A3").Value = "='[" + stuff + "]Dashboard'!$A$3"
wsSheet.Range("A4").Value = "='[" + stuff + "]Dashboard'!$A$4"
wsSheet.Range("A5").Value = "='[" + stuff + "]Dashboard'!$A$5"
wsSheet.Range("A6").Value = "='[" + stuff + "]Dashboard'!$A$6"
wsSheet.Range("B1").Value = "='[" + stuff + "]Dashboard'!$B$1"
wsSheet.Range("B2").Value = "='[" + stuff + "]Dashboard'!$B$2"
wsSheet.Range("B3").Value = "='[" + stuff + "]Dashboard'!$B$3"
wsSheet.Range("B4").Value = "='[" + stuff + "]Dashboard'!$B$4"
wsSheet.Range("B5").Value = "='[" + stuff + "]Dashboard'!$B$5"
wsSheet.Range("B6").Value = "='[" + stuff + "]Dashboard'!$B$6"
wsSheet.Range("C1").Value = "='[" + stuff + "]Dashboard'!$C$1"
wsSheet.Range("C2").Value = "='[" + stuff + "]Dashboard'!$C$2"
wsSheet.Range("C3").Value = "='[" + stuff + "]Dashboard'!$C$3"
wsSheet.Range("C4").Value = "='[" + stuff + "]Dashboard'!$C$4"
wsSheet.Range("C5").Value = "='[" + stuff + "]Dashboard'!$C$5"
wsSheet.Range("C6").Value = "='[" + stuff + "]Dashboard'!$C$6"
wsSheet.Range("D1").Value = "='[" + stuff + "]Dashboard'!$D$1"
wsSheet.Range("D2").Value = "='[" + stuff + "]Dashboard'!$D$2"
wsSheet.Range("D3").Value = "='[" + stuff + "]Dashboard'!$D$3"
wsSheet.Range("D4").Value = "='[" + stuff + "]Dashboard'!$D$4"
wsSheet.Range("D5").Value = "='[" + stuff + "]Dashboard'!$D$5"
wsSheet.Range("D6").Value = "='[" + stuff + "]Dashboard'!$D$6"
wsSheet.Range("E1").Value = "='[" + stuff + "]Dashboard'!$E$1"
wsSheet.Range("E2").Value = "='[" + stuff + "]Dashboard'!$E$2"
wsSheet.Range("E3").Value = "='[" + stuff + "]Dashboard'!$E$3"
wsSheet.Range("E4").Value = "='[" + stuff + "]Dashboard'!$E$4"
wsSheet.Range("E5").Value = "='[" + stuff + "]Dashboard'!$E$5"
wsSheet.Range("E6").Value = "='[" + stuff + "]Dashboard'!$E$6"
wsSheet.Range("F1").Value = "='[" + stuff + "]Dashboard'!$F$1"
wsSheet.Range("F2").Value = "='[" + stuff + "]Dashboard'!$F$2"
wsSheet.Range("F3").Value = "='[" + stuff + "]Dashboard'!$F$3"
wsSheet.Range("F4").Value = "='[" + stuff + "]Dashboard'!$F$4"
wsSheet.Range("F5").Value = "='[" + stuff + "]Dashboard'!$F$5"
wsSheet.Range("F6").Value = "='[" + stuff + "]Dashboard'!$F$6"


wsSheet.Range("A1:F6").Select
With Selection
.WrapText = True
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.ColumnWidth = 15
End With
ActiveWindow.Zoom = 250

wsSheet.Range("A2:F2").RowHeight = 55
wsSheet.Range("A4:F4").RowHeight = 55
wsSheet.Range("A6:F6").RowHeight = 55

Dim rg As Range
Dim cond1 As FormatCondition
Set rg = wsSheet.Range("A1:F6")
Set cond1 = rg.FormatConditions.Add(xlCellValue, xlEqual, 0)

With cond1
.Interior.Color = vbBlack
End With

wsSheet.Range("A1:A2").BorderAround , xlThick
wsSheet.Range("B1:B2").BorderAround , xlThick
wsSheet.Range("C1:C2").BorderAround , xlThick
wsSheet.Range("D1:D2").BorderAround , xlThick
wsSheet.Range("E1:E2").BorderAround , xlThick
wsSheet.Range("F1:F2").BorderAround , xlThick
wsSheet.Range("A3:B4").BorderAround , xlThick
wsSheet.Range("B3:B4").BorderAround , xlThick
wsSheet.Range("C3:C4").BorderAround , xlThick
wsSheet.Range("D3:D4").BorderAround , xlThick
wsSheet.Range("E3:E4").BorderAround , xlThick
wsSheet.Range("F3:F4").BorderAround , xlThick
wsSheet.Range("A5:B6").BorderAround , xlThick
wsSheet.Range("B5:B6").BorderAround , xlThick
wsSheet.Range("C5:C6").BorderAround , xlThick
wsSheet.Range("D5:D6").BorderAround , xlThick
wsSheet.Range("E5:E6").BorderAround , xlThick
wsSheet.Range("F5:F6").BorderAround , xlThick

ActiveWindow.DisplayGridlines = False


End Sub

10 Replies

@Al2kmontes 

Which line is highlighted if you click Debug?

ActiveWorkbook.SaveAs "G:\Training Unit\Cadet Training\Unit Folder\Instructors\Class Material\Departments\Testing\DONT DELETE.xls"

@Al2kmontes 

Try replacing the lines

 

Workbooks.Add
ActiveWorkbook.SaveAs "G:\Training Unit\Cadet Training\Unit Folder\Instructors\Class Material\Departments\Testing\DONT DELETE.xls"
Workbooks.Open Filename:="G:\Training Unit\Cadet Training\Unit Folder\Instructors\Class Material\Departments\Testing\DONT DELETE.xls"

 

with

 

Workbooks.Add.SaveAs FileName:="G:\Training Unit\Cadet Training\Unit Folder\Instructors\Class Material\Departments\Testing\DONT DELETE.xls", FileFormat:=xlExcel8

I got past that error message but now it is throwing other ones.
-the file format and extension dont match.
- cound not find.......(Path could not be found)
Run-time error '1001';
Microsoft Excel cannot access the file'G/traiing Unit\........
-The file name or path does not exist
-The fie is being used by another program

@Al2kmontes 

Could a workbook named DONT DELETE.xls exist in the specified folder?

Or is DONT DELETE.xls the name of the workbook in which the code is running?

I believe the "Could a workbook named DONT DELETE.xls exist in the specified folder?" is the issue. I need to confirm the file exists.

That is a private folder that i have requested access to.