I am at a complete loss as to why this code does not work. It gives the 'run time error 9 error'. The other workbook exists and is open after the first block of code. Any help greatly appreciated. Thanks.
Code:
' create a new workbook
Dim newWorkbook As Workbook
Set newWorkbook = Workbooks.Add
With newWorkbook
.Title = "testoutput"
.Subject = "output"
.SaveAs filename:="C:\temp\aTestOutput.xlsx"
End With
Code:
' write value to new workbook
Workbooks("C:\temp\aTestOutput.xlsx").Sheets("Sheet1").Cells(1, 1) = "output"
'Workbooks("C:\temp\aTestOutput.xlsx").Worksheets(1).Cells(1, 1) = "output"