Results 1 to 7 of 7

Thread: Current File Size of Workbook

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2003
    Posts
    406

    Current File Size of Workbook

    I have a report that I have automated. While it's running, it's visibility property is set to false.

    I have the Workbook save itself after it retrieves all the data and enters it in the correct cells/tabs.

    When it is told to save itself (using the VBA functions), and the disk is full, it just sits there....even with DisplayAlerts set to true.

    So, I want to be able to compare the current size of the workbook (it increases due to the data it gathers, or if it needs to add new tabs) to the disk space available to it.

    I saw some recomendations on using FSO, but I would prefer to avoid that.

    I also ran across 'BuiltinDocumentProperties', but unsure how to actually see the properties...I have received errors when trying to display them in a messagebox.

    Any help would be appreciated! Thanks!!

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    There is a "Number of Bytes" property but its returning an error
    for me. Maybe it can help you.
    VB Code:
    1. ActiveWorkbook.BuiltinDocumentProperties.Item ("Number of Bytes")
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2003
    Posts
    406

    Hmmmm...

    ...I am getting the errors as well...weird...

  4. #4
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    Try looping through the items collection checking the values for
    each element.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  5. #5
    Addicted Member
    Join Date
    Aug 2002
    Location
    Luton, UK
    Posts
    178
    <<current size of the workbook >>

    Code:
    MySize = FileLen("C:\TEMP\MYFILE.XLS")
    Regards
    BrianB
    -------------------------------

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2003
    Posts
    406

    Won't...

    that show the size of the workbook the last time it was saved?

  7. #7
    Addicted Member
    Join Date
    Aug 2002
    Location
    Luton, UK
    Posts
    178
    Yep. I don't think you can get a file size if it is not on disk.
    Could try looking at the .tmp file size I suppose. Problem would be nowing the file name.
    Regards
    BrianB
    -------------------------------

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width