View Single Post
 
Old 01-22-2014, 03:56 AM
macropod's Avatar
macropod macropod is offline Windows 7 32bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,360
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote