- Search ExcelTip.com
directly from Excel
- Get immediate access to the
"Tip of the Hour"
- View hundreds of Microsoft
Excel tips with a click of a button
- Absolutely
Free - Click
here to download
Make your Amazon.com purchases by clicking the graphic below
|
Excel Tip .com - Mailing List Thread Index
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to quit application properly
Ok, here is the code for both wbs. After it runs the first code, it assigns a
new name to the workbook, opens up the second wb(ITEHH.xls), runs the code,
renames the wb, closes it out, then it wants to go back to the TRANSFER code in
the initial wb. Why does it do that instead of moving on through the code to
the next line after
Application.Run ("ITEHH.XLS!Transfer2")???
Jim
Sub Transfer()'This is the code that runs first in the initial wb
Application.EnableEvents = False
Dim rngCell As Range, c As Range
Set rngCell = Range("I8:I300")
Application.DisplayAlerts = False
Workbooks.Open Filename:="C:\ftpfiles\ITE11.WK3"
Range("V8:AG152").Select
Selection.Copy
Windows("ITECAT3D.xls").Activate
Range("B8").Select
ActiveSheet.Paste
Windows("ITE11.WK3").Activate
ActiveWindow.Close
Application.DisplayAlerts = False
ActiveWindow.WindowState = xlMaximized
Application.DisplayAlerts = True
Range("F8").Select 'To find last row with info in it
Selection.End(xlDown).Offset(1, 0).Select
ActiveCell.Rows("1:500").EntireRow.Select
Selection.Clear
Range("E8").Select
For Each c In rngCell
If Len(c.Value) > 0 Then
c.Value = Trim$(c.Value)
End If
Next c
For nRow = Range("I300").End(xlUp).Row To 2 Step -1
If Right(Cells(nRow, 9), 6) = "REBATE" Then Rows(nRow).Delete
Next
ChDir "C:\Documents and Settings\JIM \My Documents\BackUp\ITEREBATES"
ActiveWorkbook.SaveAs Filename:= _
"C:\Documents and Settings\JIM \My Documents\BackUp\ITEREBATES\CAT3D"
& Month(Now()) - 1 & Year(Now()) & _ ".xls", FileFormat:=xlNormal _
, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
CreateBackup:=False
ChDir "C:\Documents and Settings\JIM \My Documents\Backup\ITEREBATES"
Workbooks.Open Filename:= _
"C:\Documents and Settings\JIM \My
Documents\Backup\ITEREBATES\ITEHH.xls"
Application.Run ("ITEHH.XLS!Transfer")
Application.ScreenUpdating = True 'Never gets this far, starts over
at top
Application.EnableEvents = True
ActiveWindow.Close savechanges:=False
Application.Quit
End Sub
Sub Transfer2()'This is the code in the second wb
Dim rngCell As Range, c As Range
Application.ScreenUpdating = False
Set rngCell = Range("h8:h300")
Application.DisplayAlerts = False
Workbooks.Open Filename:="C:\ftpfiles\ITEHH1.WK3"
Range("V8:AG152").Select
Selection.Copy
Windows("ITEHH.xls").Activate
Range("A8").Select
ActiveSheet.Paste
Windows("ITEHH1.WK3").Activate
ActiveWindow.Close
ActiveWindow.WindowState = xlMaximized
Application.DisplayAlerts = True
Range("E8").Select
Selection.End(xlDown).Offset(1, 0).Select
ActiveCell.Rows("1:500").EntireRow.Select
Selection.Clear
For Each c In rngCell
If Len(c.Value) > 0 Then
c.Value = Trim$(c.Value)
End If
Next c
For nRow = Range("I300").End(xlUp).Row To 2 Step -1
If Right(Cells(nRow, 8), 6) = "REBATE" Then Rows(nRow).Delete
Next
Range("E8").Select
ChDir "C:\Documents and Settings\JIM \My Documents\BackUp\ITEREBATES"
ActiveWorkbook.SaveAs Filename:= _
"C:\Documents and Settings\JIM \My Documents\BackUp\ITEREBATES\HH" &
Month(Now()) - 1 & Year(Now()) & ".xls", FileFormat:=xlNormal _
, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
CreateBackup:=False
ActiveWindow.Close
End Sub
In a message dated 7/28/2003 4:51:04 PM Eastern Daylight Time,
msuhaj01@SPRINTSPECTRUM.COM writes:
> As long as you have the workbook name, activate it before trying the
> close routine? I've made the mistake of thinking Excel was going to
> activate the last open sheet before and it doesn't. Perhaps posting your
> Transfer routine would give a clearer understanding?
>
> -----Original Message-----
> From: Jim . [mailto:Escojpoer@AOL.COM]
> Sent: Monday, July 28, 2003 1:46 PM
> To: EXCEL-G@PEACH.EASE.LSOFT.COM
> Subject: Re: How to quit application properly
>
> I am not having trouble saving or closing the ITEHH.XLS wb. It is the
> CAT3D
> wb from which the Application.Run is being initiated that I cannot
> close.
> Thank you,
> Jim
>
> In a message dated 7/28/2003 4:40:52 PM Eastern Daylight Time,
> msuhaj01@SPRINTSPECTRUM.COM writes:
>
> >Couple suggestions if I may..
> >
> >Perhaps putting the name of the path into a variable? This way your
> code
> >is a bit shorter.
> >
> >With the problem you are having, I'm fairly sure that if you put in
> the
> >code below it should. (untested)
> >
> >Application.Run ("ITEHH.XLS!Transfer")
> >Windows("ITEHH.xls ").Activate
> >ActiveWorkbook.Close Savechanges:=True
> >Application.Quit
> >
> >
> >-----Original Message-----
> >From: Jim . [mailto:Escojpoer@AOL.COM]
> >Sent: Monday, July 28, 2003 1:33 PM
> >To: EXCEL-G@PEACH.EASE.LSOFT.COM
> >Subject: How to quit application properly
> >
> >Hi-
> > I am trying to open a wb and run a mac in that workbook, save it
> >with
> >a filename, open the next wb, run the mac, save it with a new name,
> then
> >go
> >back and close the original, but the original will not close. It has
> >already
> >been saved with the new filename, but it and the app still remain
> open.
> >Actually
> >I have 3 wbs to open and run macs and rename, but I am just working
> with
> >these
> >two right now. Need help. At the end of this code I open ITEHH.xls and
> >run
> >mac called Transfer. It runs and saves the file with a new name and
> >closes the
> >workbook, then the wb CAT3D62003(which has already been saved once by
> >this mac)
> >just stays open. How do I close it at the end of this code?? Thankx
> > Jim
>
--------------------------------------------------------------------------
The EXCEL-G list is hosted on a Windows NT(TM) machine running L-Soft
international's LISTSERV(R) software. For subscription/signoff info
and archives, see http://peach.ease.lsoft.com/archives/excel-g.html .
COPYRIGHT INFO:
http://peach.ease.lsoft.com/scripts/wa.exe?SHOWTPL=COPYRIGHT&L=EXCEL-G
|
And at your local bookseller


Excel Training Level I
Excel
Training Level II
Excel
Training Level III
Excel
VBA Training Level I
Excel
VBA Training Level II
View All Excel Training Programs

Formula Manager
Duplication
Manager
Text
Manager
Number
Manager
Add-ins
Collection
Spreadsheet
Assistant
Number
Manager
Add-ins
Collection
Spreadsheet
Assistant
View All Excel Add-Ins
|