Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1
Default Date to close file


I'm using the date code below to close the file but just figured that if
the file is renamed this will fail. Is there code that will close the
workbook no matter what the filename to overcome this ?


Dim exdate As Date
exdate = "07/12/2009"
If Date exdate Then
MsgBox ("Sorry this spreadsheet has expired please use latest
version")
Application.DisplayAlerts = False
Workbooks("Master 09 17.50 VAT.XLS").Close
Exit Sub
End If




--
PSM
  #2   Report Post  
Junior Member
 
Posts: 6
Default

It might help to name the workbook when it is opened and then use that variable when closing. Something like this in your code:


dim wrkNewWorkbook as Workbook

'after you open workbook

wrkNewWorkbook = Activeworkbook.Name

'then after you've done whatever you need to do with the file you can close it

Workbooks(wrkNewWorkbook).Close Savechanges:=false

Or you can just use:

Activeworkbook.Close Savechanges:=false

maybe?



Quote:
Originally Posted by PSM[_20_] View Post
I'm using the date code below to close the file but just figured that if
the file is renamed this will fail. Is there code that will close the
workbook no matter what the filename to overcome this ?


Dim exdate As Date
exdate = "07/12/2009"
If Date exdate Then
MsgBox ("Sorry this spreadsheet has expired please use latest
version")
Application.DisplayAlerts = False
Workbooks("Master 09 17.50 VAT.XLS").Close
Exit Sub
End If




--
PSM
  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1
Default Date to close file


Thanks ddibble, works a treat.

'ddibble[_3_ Wrote:
;3558640']It might help to name the workbook when it is opened and then
use that
variable when closing. Something like this in your code:


dim wrkNewWorkbook as Workbook

'after you open workbook

wrkNewWorkbook = Activeworkbook.Name

'then after you've done whatever you need to do with the file you can
close it

Workbooks(wrkNewWorkbook).Close Savechanges:=false

Or you can just use:

Activeworkbook.Close Savechanges:=false

maybe?



'PSM[_20_ Wrote: -
;902734']I'm using the date code below to close the file but just
figured that if
the file is renamed this will fail. Is there code that will close the
workbook no matter what the filename to overcome this ?


Dim exdate As Date
exdate = "07/12/2009"
If Date exdate Then
MsgBox ("Sorry this spreadsheet has expired please use latest
version")
Application.DisplayAlerts = False
Workbooks("Master 09 17.50 VAT.XLS").Close
Exit Sub
End If




--
PSM-




--
ddibble





--
PSM
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
vlookup on close file Dan Excel Worksheet Functions 2 June 3rd 08 03:47 PM
Why do i lose EOMONTH on file close Jake Excel Worksheet Functions 2 May 30th 08 06:00 PM
Everytime i close an excel file, it creates a new backup file p Excel Discussion (Misc queries) 3 November 22nd 07 08:13 AM
Copy from another file and close automatically Jim G Excel Discussion (Misc queries) 2 October 17th 07 01:31 AM
File close excel does not ask me to save changes Cathy Humphreys Excel Discussion (Misc queries) 2 June 13th 05 08:48 PM


All times are GMT +1. The time now is 05:31 PM.

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

About Us

"It's about Microsoft Excel"