Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default File Properties

How can I reference the size of a spreadsheet (not necessarily the active
one) in an automated way? Ideally I want a cell in my active file to show
the size (i.e. 50k) and will change each time the active spreadsheet is
opened as the external file grows in size. Any thoughts?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 72
Default File Properties

This gives you names and sizes for all .xls files in the directory
containing the open workbook:
Sub dir_test()
Dim fs, f, s
Dim filespec As String
Dim count As Integer
count = 1
Set fs = CreateObject("Scripting.FileSystemObject")
filespec = Dir(ActiveWorkbook.Path & "\*.xls")
Do While filespec < ""
Set f = fs.GetFile(filespec)
s = f.Size
n = f.Name
Range("A" & count) = n
Range("B" & count) = s & " KB"
filespec = Dir
count = count + 1
Loop
End Sub

For one specific file:
Sub dir_test()
Dim fs, f

Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFile("H:\excel\Dir1.xls")

Range("A1") = f.Name
Range("B1") = f.Size & " KB"

End Sub

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 72
Default File Properties

I should have added, double click ThisWorkbook in the VB Editor and use:
Private Sub Workbook_Open()

to run code when a workbook is opened.


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
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
File properties Radek Simek[_2_] Excel Worksheet Functions 0 December 10th 07 03:45 PM
File Properties ALEX Excel Discussion (Misc queries) 1 February 8th 07 02:47 PM
File Properties Andrew Excel Discussion (Misc queries) 2 August 19th 05 01:23 PM
Get File Properties Jos Vens Excel Programming 2 February 10th 04 12:03 AM
Set properties in an XLS file.. S Ayyar Excel Programming 0 December 9th 03 08:51 PM


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