Smoothcat74
Technical User
- Aug 29, 2008
- 40
Hi all,
I am using VBA to open a file in Microsoft Excel in an effort to save it in 2007 format. The file being opened is a plain .txt file, but VBA returns an error because the file isn't a .xls or .xlsx (I'm assuming.) Does anyone know an effective workaround for this issue?
I am using VBA to open a file in Microsoft Excel in an effort to save it in 2007 format. The file being opened is a plain .txt file, but VBA returns an error because the file isn't a .xls or .xlsx (I'm assuming.) Does anyone know an effective workaround for this issue?
Code:
Dim Xl As Excel.Application
Dim XlBook As Excel.Workbook
Set Xl = CreateObject("Excel.Application")
Set XlBook = GetObject(ExcelPath & Format(Date, "mmmdd_yy") & ".txt")
Xl.Visible = True
XlBook.Windows(1).Visible = True
XlBook.SaveAs ExcelPath & Format(Date, "mmmdd_yy")