Hello,
Not sure why the script fails on the marked line below.
Code:
sPath = "c:\tmp\"
fln = sPath + "tmp.pptm"
strExcelPath = sPath + "tmp.xlsm"
Set objExcel = CreateObject("Excel.Application")
' sheet1 - MAIN
' sheet2 - Simulations_journal
' sheet3 - Misc
objExcel.Workbooks.Open strExcelPath
objExcel.Visible = True
Set objSheet = objExcel.ActiveWorkbook.Worksheets(2)
With objExcel
Set objSheet = objExcel.ActiveWorkbook.Worksheets(2)
LastColumn = objSheet.Cells(1, .Columns.Count).End(xlToRight).Columnc'<======== fails here
LastRow = objSheet.Cells(.Rows.Count, 4).End(xlUp).Row
End With
pako = CStr(LastRow) + Chr(10) + CStr(LastColumn)
objExcel.Cells(LastRow + 2, 1).Value = Now
objExcel.Cells(LastRow + 2, 2).Value = Now
objExcel.Cells(LastRow + 2, 3).Value = ThisWorkbook.Name
objExcel.Cells(LastRow + 3, 3).Value = ThisWorkbook.path
objExcel.Cells(LastRow + 4, 3).Value = Sheets("MAIN").Cells(20, 5).Value
objExcel.Cells(LastRow + 5, 3).Value = Sheets("MAIN").Cells(21, 5).Value
objExcel.Cells(LastRow + 6, 3).Value = Sheets("MAIN").Cells(22, 5).Value
objExcel.Cells(LastRow + 7, 3).Value = Sheets("MAIN").Cells(23, 5).Value
objExcel.Cells(LastRow + 8, 3).Value = Sheets("MAIN").Cells(24, 5).Value
objExcel.Cells(LastRow + 9, 3).Value = Sheets("MAIN").Cells(25, 5).Value
objExcel.Cells(LastRow + 10, 3).Value = Sheets("MAIN").Cells(26, 5).Value
' Excel Save, Quit and Unload
objExcel.DisplayAlerts = False
objExcel.ActiveWorkbook.Save
objExcel.ActiveWorkbook.Close
objExcel.Application.Quit
objExcel.DisplayAlerts = True
Set objExcel = Nothing