Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default Macro to Close a specific workbook.

Hello,

So what my macro does is look up on a "Macro Control" sheet of my
workbook to get different variables based on the day to open and grab
specific information. It is working fine up until the point that I
try to close it. It stops at the "Windows (FN) .Activate". Can
someone please tell me what I am doing wrong here or how I can somehow
bypass this?

Thanks so much!

Dan



Here is the part of the macro:


Dim FN As String
FN = Range("'Macro Control'!B7")
Dim FNX As String
FNX = Range("'Macro Control'!B7")
Application.DisplayAlerts = False

Workbooks.Open Filename:=FN
Range("D1:W28").Select
Selection.Copy
Windows("Daily MTM Signoff Template.xls").Activate
Sheets("Current Day CFlash Report").Select
Range("D4").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False


FN = Range("'Macro Control'!B7")
FNX = Range("'Macro Control'!B7")
Application.DisplayAlerts = False

FN = Range("'Macro Control'!B7")
Application.DisplayAlerts = False

Windows(FN).Activate
ActiveWorkbook.Close savechanges:=False
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10,124
Default Macro to Close a specific workbook.

Why are you recreating FN as you go along? Just use the FIRST FN. Try this

Dim FN As String
FN = Range("'Macro Control'!B7")
Dim FNX As String
FNX = Range("'Macro Control'!B7")

Application.DisplayAlerts = False
Workbooks.Open Filename:=FN
Range("D1:W28").Copy
Windows("Daily MTM Signoff Template.xls").Activate
Sheets("Current Day CFlash Report").Select
Range("D4").PasteSpecial Paste:=xlPasteValues
Aplication.DisplayAlerts = TRUE

Windows(FN).Activate
ActiveWorkbook.Close savechanges:=False

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Dmad11" wrote in message
...
Hello,

So what my macro does is look up on a "Macro Control" sheet of my
workbook to get different variables based on the day to open and grab
specific information. It is working fine up until the point that I
try to close it. It stops at the "Windows (FN) .Activate". Can
someone please tell me what I am doing wrong here or how I can somehow
bypass this?

Thanks so much!

Dan



Here is the part of the macro:


Dim FN As String
FN = Range("'Macro Control'!B7")
Dim FNX As String
FNX = Range("'Macro Control'!B7")
Application.DisplayAlerts = False

Workbooks.Open Filename:=FN
Range("D1:W28").Select
Selection.Copy
Windows("Daily MTM Signoff Template.xls").Activate
Sheets("Current Day CFlash Report").Select
Range("D4").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False


FN = Range("'Macro Control'!B7")
FNX = Range("'Macro Control'!B7")
Application.DisplayAlerts = False

FN = Range("'Macro Control'!B7")
Application.DisplayAlerts = False

Windows(FN).Activate
ActiveWorkbook.Close savechanges:=False


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to close workbook with prompt JMac[_2_] Excel Worksheet Functions 1 January 31st 08 05:29 PM
Macro to close workbook and re-open new copy Dave Lagergren Excel Discussion (Misc queries) 2 February 28th 07 10:11 PM
VBA Code to kick off macro when workbook command to close is initi zulfer7 Excel Discussion (Misc queries) 2 June 23rd 06 08:04 PM
Macro to copy specific cells from one workbook to another [email protected] Excel Discussion (Misc queries) 4 June 9th 06 04:32 PM
run macro on workbook close Nigel Excel Discussion (Misc queries) 3 November 29th 05 08:48 PM


All times are GMT +1. The time now is 06:15 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"