Results 1 to 5 of 5

Thread: Excel H/D Serial Number (resolved)

  1. #1

    Thread Starter
    Lively Member TheFIDDLER's Avatar
    Join Date
    May 2002
    Location
    here and there and far away
    Posts
    126

    Excel H/D Serial Number (resolved)

    I need some help with this. I use this code to get the serial number of my drive. Works well in XP, does not work in 98. I need a code that will work for all windows versions. Any suggestions? This is run by my autoopen subroutine in Excel 97.

    VB Code:
    1. Private Sub snumber()
    2. ' checks serial number of hard disk and stores to name value
    3.     Dim fso, d
    4.     Dim s As Long
    5.     Set fso = CreateObject("Scripting.FileSystemObject")
    6.     Set d = fso.GetDrive(Left(ThisWorkbook.Path, 2))
    7.     s = d.serialnumber
    8.     Names.add Name:="SerialNumber", RefersTo:=Abs(s), Visible:=False
    9.    
    10. End Sub

    Thanks.
    Last edited by TheFIDDLER; May 6th, 2004 at 04:59 PM.
    -----
    #VBA, VB 6 Professional Edition, Office XP Developper. Excel 97, Excel 2000, Excel XP

    I miss my VIC 20.
    Never should have upgraded to my commodore 64. ...

  2. #2
    Addicted Member
    Join Date
    Dec 2001
    Posts
    158
    I was curious enough to look around for a few seconds.

    I found this,
    http://www.excelforum.com/t209535-s

    But got boerd a few posts down.

  3. #3
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    I would go with the API method over the FSO anyday. Faster and
    will work on 95 on up and NT 3.51 and up. Check this site for all
    your API needs (serial # examples at bottom of page).

    allapi.net
    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

  4. #4

    Thread Starter
    Lively Member TheFIDDLER's Avatar
    Join Date
    May 2002
    Location
    here and there and far away
    Posts
    126
    Thanks, will work on it and see if we can improve our code. The API site had what I was looking for.

    I'm still curious about my code - since I have one user that code an error "Unable To create Object" in Win98 with the FSO method. But looking back in my records, I have several succesful Win98 installations listed.

    I think I will code a double approach. Still using FSO, but coding an OnError that will launch the API call, either way, that makes it more secure that I get my serial number, no matter the platform.
    Last edited by TheFIDDLER; May 6th, 2004 at 08:35 PM.
    -----
    #VBA, VB 6 Professional Edition, Office XP Developper. Excel 97, Excel 2000, Excel XP

    I miss my VIC 20.
    Never should have upgraded to my commodore 64. ...

  5. #5
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    No problem, but I still suggest using the API over FSO.

    The one error on 98 with not being able to create object is that
    system is missing the scripting dependancy files.
    FSO = Windows Scripting Host Object Model (wshom.ocx) reference.
    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

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