David Jenkins
New Member
Hi there,
I recorded a macro to complete what I wanted the spreadsheet to do and then place it in the workbook_open event.
I can see that it creates and saves the new workbook, but then give me the error when it tries to activate it.
Could this be because when I try to open the saved .xls file it tells me that it is not in the specified format?
Regards,
Dave.
I recorded a macro to complete what I wanted the spreadsheet to do and then place it in the workbook_open event.
I can see that it creates and saves the new workbook, but then give me the error when it tries to activate it.
Code:
Sub Workbook_Open()
'Create a new workbook
Dim Wk As Workbook
Set Wk = Workbooks.Add
Application.DisplayAlerts = False
Wk.SaveAs Filename:="\\cpwplc.com\data\data_perfplan\MI Team\Reporting\KPI Grid\Saved Files\KPI_Grid.xls", FileFormat:=xlExcel8, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
Cells.Select
Range("B1").Activate
Selection.Copy
Windows("KPI_Grid.xls").Activate '******* errors here ***********
Cells.Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
ActiveWindow.DisplayGridlines = False
Sheets("Sheet1").Select
Sheets("Sheet1").Name = "Weekly"
Range("B1:E1").Select
Windows("KPI Grid V5k1 - macro testing.xlsm").Activate
Sheets("Monthly").Select
Cells.Select
Range("B1").Activate
Application.CutCopyMode = False
Selection.Copy
Windows("KPI_Grid.xls").Activate
Sheets("Sheet2").Select
Cells.Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
ActiveWindow.DisplayGridlines = False
Sheets("Sheet2").Select
Sheets("Sheet2").Name = "Monthly"
Range("B1:E1").Select
Application.CutCopyMode = False
ChDir "\\cpwplc.com\data\data_perfplan\MI Team\Reporting\KPI Grid\Saved Files"
ActiveWorkbook.SaveAs Filename:= _
"\\cpwplc.com\data\data_perfplan\MI Team\Reporting\KPI Grid\Saved Files\KPI_Grid.xls" _
, FileFormat:=xlExcel8, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
ActiveWorkbook.Close
End Sub
Could this be because when I try to open the saved .xls file it tells me that it is not in the specified format?
Regards,
Dave.