Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Saving Excel 2007 file in 2003 creates very large file | Excel Discussion (Misc queries) | |||
Generate a file name by date.... | Excel Discussion (Misc queries) | |||
I get a file in use message telling me that the file is locked ? | New Users to Excel | |||
Macro to generate a file from another | Excel Worksheet Functions | |||
Generate File Property | Excel Discussion (Misc queries) |