PDA

View Full Version : Retrieve Date from NTP server with VBA



davidbenson3
03-03-2008, 11:02 AM
:dunno
I currently have a VBA macro in Excel that uses Now() to populate a date variable. The variable is used internally to prompt a user to renew if the license has expired. Since a user can easily bypass this by changing the computer system date, I would like to find some VBA code that will first attempt to retrieve a current date from a source on the internet and populate the variable with that value instead. If any errors occur, or the person doesn't have an active internet connection, it could still use Now() as a fallback option. Is this possible? Thanks in advance for any assistance! :thumb
David

Ago
03-03-2008, 04:02 PM
you could lock the clock in windows and put password on the biosmenu.
i dont know how to lock the wondows clock but i know it can be done.

davidbenson3
03-03-2008, 07:05 PM
Thanks for your reply. The Excel-based program that uses the macro would be downloaded and used by different individuals. The macro is actually a prompt for the user to renew a licence after one year. Right now, though, it's too easy to bypass the renewal.
When the Excel file is opened on any computer, it needs a way to check the current date from a separate source, like an NTP server.
David

Ago
03-04-2008, 01:56 AM
ok. i thought it was on a public pc.

it should be possible. i dont know how, im not good enough.

but when i look at these macros
http://vbaexpress.com/kb/getarticle.php?kb_id=386

http://vbaexpress.com/kb/getarticle.php?kb_id=399

something tells me it should be possible.

maybe someone thats better at VBA knows how to convert these macros to the usage david needs?

RonMcK
03-04-2008, 11:03 AM
David,

I'm not aware of a utility program that is part of the Windows operating system that you can use to execute an on-demand synchronization of the system clock of a PC.

W32Time.exe (or TimeServ.exe under NT4) starts a service that can be configured to poll a NTP (network time protocol) server to syncrhornize the clock. Since setup and configuration is required, this option probably will not meet your needs.

Would it be possible for your worksheet to capture and save the date/time stamp when first opened? And, then, have a day counter to track subsequent opens/use? Might you be able to calculate the usage period rather than relying solely on what the NOW() function tells your worksheet when it opens?

Thanks,

Ron
Orlando, FL