Greetings,
Someone I work with has a macro problem and I'm trying to help out with it...hoping someone here can shed some light. He has a process set up in his Scheduler to open and Excel file every morning at 9:00 am. When it opens, the current macro triggers, adds a new worksheet, retrieves some information from an outside source, cleans up the data, and saves off the file. At that point he's wanting it to close the file AND the Excel window, because when it runs on his off days, the Excel window will not close following the macro, and the macro won't work the next time. So, there's the question. How do we get the Excel Window to close afterwards. He's said he's tried a bunch of different commands, but they don't work, especially after the file closes (which makes sense). I suggested a Personal Macro Workbook to hold the macro, but don't know if that would work or not, and we can't get it to close the window anyway. Here's the current code, if anyone can help with it. Thanks in advance.
Sub Autpen()
'
' Macro7 Macro
' Macro recorded 8/14/2007
'
'
Sheets.Add
ActiveCell.FormulaR1C1 = "=TODAY()"
Range("A2").Select
ActiveWorkbook.XmlImport URL:=" ImportMap:= _
Nothing, Overwrite:=True, Destination:=Range("$A$2")
Selection.AutoFilter Field:=5, Criteria1:="<>0", Operator:=xlAnd
Range("E3:E115").Select
Selection.NumberFormat = "$#,##0.00"
Cells.Select
Cells.EntireColumn.AutoFit
Range("A123").Select
ActiveCell.FormulaR1C1 = "=TODAY()"
Selection.Copy
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("G27").Select
Application.CutCopyMode = False
Selection.Delete Shift:=xlToLeft
Range("A1").Select
ActiveWorkbook.Save
ActiveWorkbook.Close
ActiveWindow.Close
End Sub
Someone I work with has a macro problem and I'm trying to help out with it...hoping someone here can shed some light. He has a process set up in his Scheduler to open and Excel file every morning at 9:00 am. When it opens, the current macro triggers, adds a new worksheet, retrieves some information from an outside source, cleans up the data, and saves off the file. At that point he's wanting it to close the file AND the Excel window, because when it runs on his off days, the Excel window will not close following the macro, and the macro won't work the next time. So, there's the question. How do we get the Excel Window to close afterwards. He's said he's tried a bunch of different commands, but they don't work, especially after the file closes (which makes sense). I suggested a Personal Macro Workbook to hold the macro, but don't know if that would work or not, and we can't get it to close the window anyway. Here's the current code, if anyone can help with it. Thanks in advance.
Sub Autpen()
'
' Macro7 Macro
' Macro recorded 8/14/2007
'
'
Sheets.Add
ActiveCell.FormulaR1C1 = "=TODAY()"
Range("A2").Select
ActiveWorkbook.XmlImport URL:=" ImportMap:= _
Nothing, Overwrite:=True, Destination:=Range("$A$2")
Selection.AutoFilter Field:=5, Criteria1:="<>0", Operator:=xlAnd
Range("E3:E115").Select
Selection.NumberFormat = "$#,##0.00"
Cells.Select
Cells.EntireColumn.AutoFit
Range("A123").Select
ActiveCell.FormulaR1C1 = "=TODAY()"
Selection.Copy
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("G27").Select
Application.CutCopyMode = False
Selection.Delete Shift:=xlToLeft
Range("A1").Select
ActiveWorkbook.Save
ActiveWorkbook.Close
ActiveWindow.Close
End Sub