|
-
May 4th, 2004, 09:04 PM
#1
Thread Starter
Lively Member
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:
Private Sub snumber()
' checks serial number of hard disk and stores to name value
Dim fso, d
Dim s As Long
Set fso = CreateObject("Scripting.FileSystemObject")
Set d = fso.GetDrive(Left(ThisWorkbook.Path, 2))
s = d.serialnumber
Names.add Name:="SerialNumber", RefersTo:=Abs(s), Visible:=False
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. ...
-
May 4th, 2004, 09:11 PM
#2
Addicted Member
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.
-
May 6th, 2004, 11:16 AM
#3
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
May 6th, 2004, 04:58 PM
#4
Thread Starter
Lively Member
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. ...
-
May 6th, 2004, 05:05 PM
#5
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|