In your code you have:
On Error Resume Next
AppActivate ("Microsoft excel")
Set ExcelSheet = CreateObject("Excel.Application")
What this is doing is telling the macro to ignore any errors, activate the current Excel seesion (if this is one) then start another Excel session - regardless of whether Excel is already running ...
Defining the Excel application as 'ExcelSheet' is poor practice, as it could lead to confusion as to whether you're working with a worksheet or the application behind the workbook containing a worksheet. IMHO you should use something like 'xlApp' for the application, 'xlWkBk' for a workbook and 'xlWkSht' for a worksheet.
Subsequently, your lines:
FileSaveAs Name:="D:\Task List Templates\Task Lists\" & mystring & ".xls", FormatID:="MSProject.XLS5", map:="Steria Task Lists"
ActiveWorkbook.Close
are unqualified, in that they don't refer to either the owning application or the particular workbook (i.e. as defined by 'xlWB').
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
|