ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   help with macro to open and close workbooks (https://www.excelbanter.com/excel-programming/277724-help-macro-open-close-workbooks.html)

aneurin

help with macro to open and close workbooks
 
all this macro does is save the Summary Report Master worbook and
create a copy of it in another folder
everything works fine up untill this point
as you can see i then select the workbook Data Summary Report Query
and try to close it
but it will not close
can anyone point me in the right direction
cheers
aneurin

Sub Main()
Sheets("Data Summary").Select
Range("A6").Select
ChDir "c:\Documents and Settings\Desktop"
Workbooks.Open Filename:= _
"c:\Documents and Settings\Desktop\Summary Report Master.xls"
Sheets("Data Summary").Select
Windows("Data Summary Report Query.xls").Activate
Range("a1:h20").Select
Selection.Copy
Windows("Data Summary Report Master.xls").Activate
Sheets("Data Summary").Select
Range("A6").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone,
SkipBlanks:= _
False, Transpose:=False
Range("A6").Select
Windows("Data Summary Report master.xls").Activate
Application.Run "'Data Summary Report master.xls'!saveit"
Windows("Data Summary Report Query.xls").Activate
Sheets("data summary").Select
Range("a1").Select
'saveitn
Application.DisplayAlerts = False
ActiveWorkbook.Close
End Sub

mandy_less[_6_]

help with macro to open and close workbooks
 
hi

correct me if i'm wrong... but i think perhaps u need to close the
active window, * ActiveWindow.Close * instead of * ActiveWorkbook.Close
* (2nd last line)

cheers



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/



All times are GMT +1. The time now is 11:44 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com