Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 144
Default Need to generate a msgbox telling how large the file is

Hi all,

I would like to like have a msgbox come up during Workbook_Open only when
the size of the file being opened exceeds a certain size (ie - 30 MB). I'm
wondering what the best way is to this - I'm at a loss on how to even begin
the coding to look for the file size.

Thanks for your help!

--
Robert
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Need to generate a msgbox telling how large the file is

On Apr 14, 12:18*pm, robs3131
wrote:
Hi all,

I would like to like have a msgbox come up during Workbook_Open only when
the size of the file being opened exceeds a certain size (ie - 30 MB). *I'm
wondering what the best way is to this - I'm at a loss on how to even begin
the coding to look for the file size.

Thanks for your help!

--
Robert


Robert,

See this post, which uses the filelen function:

http://en.allexperts.com/q/Excel-105...Excel-file.htm

So, providing the document has been saved (which it has by the sounds
of your post), then you could use something like this:

Private Sub Workbook_Open()
If FileLen(ThisWorkbook.FullName) = 31457280 Then
MsgBox ("Your prompt here")
End If
End Sub

31457280 is 30Mb in Bytes; and you can then use MsgBox to display
whatever message you want.

Regards,

Alex
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 54
Default Need to generate a msgbox telling how large the file is

Cresate a reference (tools references) to the Micrsoft scripting runtime
library
and then place the following in the workbook open event procedu

Dim fso As New FileSystemObject
Dim fil As File
Dim dblSize As Double

Set fil = fso.GetFolder(ThisWorkbook.Path).Files(ThisWorkboo k.Name)
dblSize = fil.Size / 1000000
If dblSize 30 Then
MsgBox "This file is " & fil.Size / 1000000 & "MB"
End If
Set fso = Nothing
Set fil = Nothing

"robs3131" wrote:

Hi all,

I would like to like have a msgbox come up during Workbook_Open only when
the size of the file being opened exceeds a certain size (ie - 30 MB). I'm
wondering what the best way is to this - I'm at a loss on how to even begin
the coding to look for the file size.

Thanks for your help!

--
Robert

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Need to generate a msgbox telling how large the file is

Rob,

Not tested because I didn't have a workbook large enough but this should do
it.

Private Sub Workbook_Open()
Path = ThisWorkbook.FullName
If FileLen(Path) / 1024 / 1024 30 Then
MsgBox FileLen(Path) / 1024 / 1024 & " Megabytes"
End If
End Sub

Mike

"robs3131" wrote:

Hi all,

I would like to like have a msgbox come up during Workbook_Open only when
the size of the file being opened exceeds a certain size (ie - 30 MB). I'm
wondering what the best way is to this - I'm at a loss on how to even begin
the coding to look for the file size.

Thanks for your help!

--
Robert

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 144
Default Need to generate a msgbox telling how large the file is

Thanks Alex! Works perfect.

--
Robert


"Alex Simmons" wrote:

On Apr 14, 12:18 pm, robs3131
wrote:
Hi all,

I would like to like have a msgbox come up during Workbook_Open only when
the size of the file being opened exceeds a certain size (ie - 30 MB). I'm
wondering what the best way is to this - I'm at a loss on how to even begin
the coding to look for the file size.

Thanks for your help!

--
Robert


Robert,

See this post, which uses the filelen function:

http://en.allexperts.com/q/Excel-105...Excel-file.htm

So, providing the document has been saved (which it has by the sounds
of your post), then you could use something like this:

Private Sub Workbook_Open()
If FileLen(ThisWorkbook.FullName) = 31457280 Then
MsgBox ("Your prompt here")
End If
End Sub

31457280 is 30Mb in Bytes; and you can then use MsgBox to display
whatever message you want.

Regards,

Alex



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 144
Default Need to generate a msgbox telling how large the file is

This worked great! Thanks Mike! And thanks to all others that responded.
--
Robert


"Mike H" wrote:

Rob,

Not tested because I didn't have a workbook large enough but this should do
it.

Private Sub Workbook_Open()
Path = ThisWorkbook.FullName
If FileLen(Path) / 1024 / 1024 30 Then
MsgBox FileLen(Path) / 1024 / 1024 & " Megabytes"
End If
End Sub

Mike

"robs3131" wrote:

Hi all,

I would like to like have a msgbox come up during Workbook_Open only when
the size of the file being opened exceeds a certain size (ie - 30 MB). I'm
wondering what the best way is to this - I'm at a loss on how to even begin
the coding to look for the file size.

Thanks for your help!

--
Robert

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
Saving Excel 2007 file in 2003 creates very large file Jon Pearce Excel Discussion (Misc queries) 2 July 16th 09 07:20 PM
Generate a file name by date.... mlindsey54 Excel Discussion (Misc queries) 5 June 23rd 09 05:49 AM
I get a file in use message telling me that the file is locked ? Dave Hastings New Users to Excel 0 November 10th 07 05:36 PM
Macro to generate a file from another Dileep Chandran Excel Worksheet Functions 10 December 4th 06 02:52 PM
Generate File Property Pastel Hughes Excel Discussion (Misc queries) 7 July 27th 06 12:58 PM


All times are GMT +1. The time now is 01:10 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"