Wrathchild
Technical User
Using Office XP I have the module:
Function FormatExcel()
Dim ExcelApp As Object
Dim myPath
myPath = "\\dir\Refund.xls"
Set ExcelApp = GetObject(myPath, "Excel.Sheet".ActiveSheet
ExcelApp.ActiveSheet.Cells.Select
ExcelApp.ActiveSheet.Cells.EntireColumn.AutoFit
ExcelApp.Save
ExcelApp.Close
End Function
I would like to open the Excel sheet, select everything and autofit all the columns, save it then close it. I got the code from a posting for Excel 97 so I'm sure it's something to do with that as to why it's not working. It does open the spreadsheet then errors on the selecting cells line. Thanks in advance!
Function FormatExcel()
Dim ExcelApp As Object
Dim myPath
myPath = "\\dir\Refund.xls"
Set ExcelApp = GetObject(myPath, "Excel.Sheet".ActiveSheet
ExcelApp.ActiveSheet.Cells.Select
ExcelApp.ActiveSheet.Cells.EntireColumn.AutoFit
ExcelApp.Save
ExcelApp.Close
End Function
I would like to open the Excel sheet, select everything and autofit all the columns, save it then close it. I got the code from a posting for Excel 97 so I'm sure it's something to do with that as to why it's not working. It does open the spreadsheet then errors on the selecting cells line. Thanks in advance!