The VBA code that check size of file in bytes ! (1 Viewer)

nhtuan

New member
Local time
Today, 12:11
Joined
Dec 23, 2010
Messages
24
Code:
Private Sub Command0_Click()
'This will return the size of your file in a MsgBox prompt
MsgBox "The attachment size is " & Format(FileLen("C:\Users\Documents\Data\myFile.docx") / 1024 / 1024, "0.00 Mb")
End Sub
 

KitaYama

Well-known member
Local time
Tomorrow, 04:11
Joined
Jan 6, 2022
Messages
1,541
You can also use FSO
Code:
    Dim FSO As Object
    Set FSO = CreateObject("Scripting.FileSystemObject")
    Debug.Print FSO.GetFile("C:\Work\test.pdf").Size
 

nhtuan

New member
Local time
Today, 12:11
Joined
Dec 23, 2010
Messages
24
You can also use FSO
Code:
    Dim FSO As Object
    Set FSO = CreateObject("Scripting.FileSystemObject")
    Debug.Print FSO.GetFile("C:\Work\test.pdf").Size
Thank you for sharing.
 

Users who are viewing this thread

Top Bottom