![]() |
closing an excel application
using excel and its VBA I have a process that reads text
data and formats and saves the result in excel workbook. I now want to completely exit the EXCEL application VBA code. I close the workbook ok but I can close the excel app. Again I'm in an excel app already and now want the VBA to quit it. |
closing an excel application
|
closing an excel application
K,
I have tried that but the excel app remains open. Here's the code Thanks in advance Sub Auto_Open() ' ' Auto_Open Macro ' Macro recorded 1/7/99 by Joe Franchina ' ' Dim newname, fName As String If FileLen("c:\temp\pqs.txt") < 0 Then ' Workbooks.OpenText FileName:="C:\TEMP\pqs.txt", Origin:=xlWindows, _ ' StartRow:=1, DataType:=xlFixedWidth, FieldInfo:=Array(Array(0, 2), Array(6, _ ' 2), Array(33, 2), Array(40, 2), Array(44, 2), Array(58, 3), Array(69, 1), Array(80, 3), _ ' Array(91, 2), Array(102, 2), Array(112, 2), Array (124, 2), Array(133, 2), Array(141, 2), _ ' Array(146, 2), Array(174, 2), Array(194, 2), Array (203, 2), Array(208, 2), Array(213, 2), _ ' Array(218, 2), Array(223, 3), Array(244, 2), Array (255, 2), Array(260, 2), Array(265, 2), _ ' Array(275, 3), Array(285, 3), Array(295, 3)) Workbooks.OpenText FileName:="C:\TEMP\pqs.txt", Origin:=xlWindows, _ StartRow:=1, DataType:=xlFixedWidth, FieldInfo:=Array(Array(0, 2), Array(6, _ 2), Array(33, 2), Array(40, 2), Array(44, 2), Array (58, 3), Array(71, 3), Array(82, 2), _ Array(93, 2), Array(104, 2), Array(113, 2), Array (118, 2), Array(146, 2), Array(166, 2), _ Array(175, 2), Array(180, 2), Array(185, 2), Array (190, 2), Array(195, 3), Array(216, 3), _ Array(226, 2), Array(231, 2), Array(236, 3), Array (248, 3), Array(260, 3), Array(270, 3), _ Array(280, 3)) Rows("1:1").Select With Selection .HorizontalAlignment = xlGeneral .VerticalAlignment = xlBottom .WrapText = True .Orientation = 0 .ShrinkToFit = False .MergeCells = False End With Columns("A:A").EntireColumn.AutoFit Columns("B:B").EntireColumn.AutoFit Columns("C:C").EntireColumn.AutoFit Columns("D:D").EntireColumn.AutoFit Columns("E:E").ColumnWidth = 14 Columns("F:F").EntireColumn.AutoFit Columns("G:G").EntireColumn.AutoFit Columns("F:G").Select Selection.NumberFormat = "mm/dd/yyyy" Columns("I:I").ColumnWidth = 9.43 Columns("J:J").EntireColumn.AutoFit Columns("K:K").EntireColumn.AutoFit Columns("L:L").ColumnWidth = 11.57 Columns("M:M").ColumnWidth = 14.43 Columns("N:N").ColumnWidth = 5.14 Columns("O:O").ColumnWidth = 1.71 Columns("P:P").ColumnWidth = 2 Columns("Q:Q").ColumnWidth = 2 Columns("R:R").ColumnWidth = 2 Columns("S:S").ColumnWidth = 12.29 Columns("T:T").ColumnWidth = 9.43 Columns("S:T").Select Selection.NumberFormat = "mm/dd/yyyy" Columns("U:U").ColumnWidth = 1.71 Columns("V:V").ColumnWidth = 1.71 Columns("W:AA").Select Selection.NumberFormat = "mm/dd/yyyy" Rows("1:1").Select Selection.AutoFilter today = Date$ newname = "PQS" ActiveSheet.Select ActiveSheet.Name = newname fName = Dir("c:\temp\pqs.xls") If fName < "" Then Kill "c:\temp\pqs.xls" End If ActiveWorkbook.SaveAs FileName:="c:\temp\pqs.xls", FileFormat:= _ xlNormal, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False _ , CreateBackup:=False ActiveWorkbook.Close Windows("autoloadpqs.xls").Activate ActiveWorkbook.Close Else MsgBox ("File c:\temp\pqs.txt is empty, check IBM logon or PQS.DATA") End If Application.Quit End Sub -----Original Message----- Use: Application.Quit K --- Message posted from http://www.ExcelForum.com/ . |
closing an excel application
Replace the second ActiveWorkbook.Close with Application.Quit. When yo
close the workbook, you are essentially exiting out of the subroutin (I think). It didn't work when I tested: Sub Test() ActiveWorkbook.Close Application.Quit End Sub But did when I removed the .Close. -- Message posted from http://www.ExcelForum.com |
closing an excel application
Thanks so much. You hit it right on the nose. the
replace of the workbook.close with the app.quit worked perfectly. Joe -----Original Message----- Replace the second ActiveWorkbook.Close with Application.Quit. When you close the workbook, you are essentially exiting out of the subroutine (I think). It didn't work when I tested: Sub Test() ActiveWorkbook.Close Application.Quit End Sub But did when I removed the .Close. K --- Message posted from http://www.ExcelForum.com/ . |
All times are GMT +1. The time now is 11:16 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com