Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

recording excel file size in a variable 1

Status
Not open for further replies.

sahmiele

Technical User
Sep 9, 2003
67
US
I am in Excel, and would like to record the active file size into a a variable. I can't seem to find the code to do this. Any suggestions?
 
sahmiele,
[tt]FileLen(ActiveWorkbook.Path & "\" & ActiveWorkbook.Name)[/tt]

Hope this helps,
CMP

[small]For the best results do what I'm thinking, not what I'm saying.[/small]
(GMT-07:00) Mountain Time (US & Canada)
 
awesome, thanks. Also, is there a simple way to do the same thing with a folder if I have the path name?
 
sahmiele,
On the first post you can use [tt]ActiveWorkbook.FullName[/tt] instead of concatenating the [tt]Path[/tt] and [tt]Name[/tt].

For Folder inforamtion I beleive the only way to get that is to use the [tt]FileSystemObject[/tt].
Code:
Function ThisWorkbookFolderSize() As Long
Dim objFSO As Object
Set objFSO = CreateObject("Scripting.FileSystemObject")
'This will cause an error if the workbook is not saved
Set objFSO = objFSO.GetFolder(ThisWorkbook.Path)
ThisWorkbookFolderSize = objFSO.Size
Set objFSO = Nothing
End Function

Hope this helps,
CMP

[small]For the best results do what I'm thinking, not what I'm saying.[/small]
(GMT-07:00) Mountain Time (US & Canada)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top