Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Get File Size (Number of Bytes) of Active Workbook

I need to populate a cell with the current file size of the active workbook.
I have tried:

Function FileSize(I As Integer)
FileSize = ThisWorkbook.BuiltinDocumentProperties(I)
End Function

and called the function in the sheet with:
=FileSize(22) ' 22 being the code for "Number of Bytes"
I get a #VALUE! error.

But if I use:
=FileSize(3) '3 being the code for "Author"
it works properly.

Any ideas?

Thanks,
Dave



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Get File Size (Number of Bytes) of Active Workbook

Firstly,

it is not a good idea to use the index, you cannot rely on it always being
the same, better to use the property name. But in this case it seems to make
no difference.

Some of the properties apply to some products, n umber of slides is clearly
PowerPoint, so maybe Number of Bytes does not apply to Excel.

--
HTH

Bob Phillips

"dflayfield" wrote in message
...
I need to populate a cell with the current file size of the active

workbook.
I have tried:

Function FileSize(I As Integer)
FileSize = ThisWorkbook.BuiltinDocumentProperties(I)
End Function

and called the function in the sheet with:
=FileSize(22) ' 22 being the code for "Number of Bytes"
I get a #VALUE! error.

But if I use:
=FileSize(3) '3 being the code for "Author"
it works properly.

Any ideas?

Thanks,
Dave





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Get File Size (Number of Bytes) of Active Workbook

Not all BuiltInDocument properties are maintained by Excel. For
file size, try

Function FileSize()
FileSize = FileLen(ThisWorkbook.FullName)
End Function


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"dflayfield" wrote in
message
...
I need to populate a cell with the current file size of the
active workbook.
I have tried:

Function FileSize(I As Integer)
FileSize = ThisWorkbook.BuiltinDocumentProperties(I)
End Function

and called the function in the sheet with:
=FileSize(22) ' 22 being the code for "Number of Bytes"
I get a #VALUE! error.

But if I use:
=FileSize(3) '3 being the code for "Author"
it works properly.

Any ideas?

Thanks,
Dave





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Get File Size (Number of Bytes) of Active Workbook

Thanks Chip,
That worked perfectly. This is probably a stupid question, but any idea how
to force the file size value to refresh periodically or after the most recent
save?

"Chip Pearson" wrote:

Not all BuiltInDocument properties are maintained by Excel. For
file size, try

Function FileSize()
FileSize = FileLen(ThisWorkbook.FullName)
End Function


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"dflayfield" wrote in
message
...
I need to populate a cell with the current file size of the
active workbook.
I have tried:

Function FileSize(I As Integer)
FileSize = ThisWorkbook.BuiltinDocumentProperties(I)
End Function

and called the function in the sheet with:
=FileSize(22) ' 22 being the code for "Number of Bytes"
I get a #VALUE! error.

But if I use:
=FileSize(3) '3 being the code for "Author"
it works properly.

Any ideas?

Thanks,
Dave






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Get File Size (Number of Bytes) of Active Workbook

Add

Application.Volatile True

as the first line of code in the function. This will cause the
function to refresh every time a calculation is made.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"dflayfield" wrote in
message
...
Thanks Chip,
That worked perfectly. This is probably a stupid question, but
any idea how
to force the file size value to refresh periodically or after
the most recent
save?

"Chip Pearson" wrote:

Not all BuiltInDocument properties are maintained by Excel.
For
file size, try

Function FileSize()
FileSize = FileLen(ThisWorkbook.FullName)
End Function


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"dflayfield" wrote in
message
...
I need to populate a cell with the current file size of the
active workbook.
I have tried:

Function FileSize(I As Integer)
FileSize = ThisWorkbook.BuiltinDocumentProperties(I)
End Function

and called the function in the sheet with:
=FileSize(22) ' 22 being the code for "Number of Bytes"
I get a #VALUE! error.

But if I use:
=FileSize(3) '3 being the code for "Author"
it works properly.

Any ideas?

Thanks,
Dave










  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Get File Size (Number of Bytes) of Active Workbook

Thanks again for your help. You solved my problem.

"Chip Pearson" wrote:

Add

Application.Volatile True

as the first line of code in the function. This will cause the
function to refresh every time a calculation is made.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"dflayfield" wrote in
message
...
Thanks Chip,
That worked perfectly. This is probably a stupid question, but
any idea how
to force the file size value to refresh periodically or after
the most recent
save?

"Chip Pearson" wrote:

Not all BuiltInDocument properties are maintained by Excel.
For
file size, try

Function FileSize()
FileSize = FileLen(ThisWorkbook.FullName)
End Function


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"dflayfield" wrote in
message
...
I need to populate a cell with the current file size of the
active workbook.
I have tried:

Function FileSize(I As Integer)
FileSize = ThisWorkbook.BuiltinDocumentProperties(I)
End Function

and called the function in the sheet with:
=FileSize(22) ' 22 being the code for "Number of Bytes"
I get a #VALUE! error.

But if I use:
=FileSize(3) '3 being the code for "Author"
it works properly.

Any ideas?

Thanks,
Dave









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
worksheet size in bytes Tamas Nagy Excel Discussion (Misc queries) 2 October 11th 05 04:15 PM
Reducing file size (for archiving, not active files) Shadhi Excel Programming 0 March 31st 05 12:21 AM
I can't adjust the window size of an active workbook. Julie Excel Discussion (Misc queries) 1 January 26th 05 05:19 PM
How to get the size of the excel file, a sheet size (in bytes)? bookworm98[_13_] Excel Programming 1 January 28th 04 02:59 PM
Determine active file size pk Excel Programming 1 October 27th 03 03:46 PM


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