Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default code to check file size everytime an Excel file is opened

Hello,

Every time any Excel file is opened, I'd like Excel to automatically
check the size of the file being opened and if it is greater than say,
5mb, I'd like Manual calculate to be turned on. Is there a way to do
this?

The workbook_open event etc. wouldn't work since then I would have to
include this macro in every single Excel workbook I ever create or that
already exists. Having the macro in the xlstart folder etc. doesn't
work either since the macro there doesn't seem to be run before the
file is opened.

Is there a way to do this using VBA? or VB6? or at the command line?

Thanks,

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default code to check file size everytime an Excel file is opened


Sub FileSize()
Dim oFSO
Dim oFile
Dim oSourceFile
oSourceFile = "D:/Excel/test.xls"
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oFile = oFSO.GetFile(oSourceFile)
If oFile.Size 5000000 Then
Application.Calculation = xlManual
End If
Set oFile = Nothing
Set oFSO = Nothing
End Sub


--
raypayette


------------------------------------------------------------------------
raypayette's Profile: http://www.excelforum.com/member.php...o&userid=29569
View this thread: http://www.excelforum.com/showthread...hreadid=566359

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default code to check file size everytime an Excel file is opened

It might be easier to set calculation to manual, then if the file is small
enough, turn it back on after the file is opened.

you would need to use application level events to turn it on.

http://www.cpearson.com/excel/appevent.htm

Do that in the personal.xls or an addin.

--
Regards,
Tom Ogilvy

"Kaiser" wrote in message
ups.com...
Hello,

Every time any Excel file is opened, I'd like Excel to automatically
check the size of the file being opened and if it is greater than say,
5mb, I'd like Manual calculate to be turned on. Is there a way to do
this?

The workbook_open event etc. wouldn't work since then I would have to
include this macro in every single Excel workbook I ever create or that
already exists. Having the macro in the xlstart folder etc. doesn't
work either since the macro there doesn't seem to be run before the
file is opened.

Is there a way to do this using VBA? or VB6? or at the command line?

Thanks,



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
Check a sheet each time file opened? Don Excel Discussion (Misc queries) 1 February 24th 09 06:27 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
How can I check the file size of each worksheet in an Excel Doc Chris1707 Excel Discussion (Misc queries) 2 January 3rd 07 06:31 PM
A new sequence number in file everytime it is opened Tiger Claw Excel Worksheet Functions 1 June 15th 05 03:37 PM
Possible to write VBA code to send out an EMAIL everytime a workbook is opened? Marcello do Guzman[_2_] Excel Programming 4 September 2nd 04 07:59 AM


All times are GMT +1. The time now is 03:25 AM.

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"