About a year ago, a manager in another department brainstormed that I could code up some VBA to auto call me in the event one of my automated reports crashes. I laughed at the time, but my skills have improved considerably and I wonder if it's technically possible
(not that I'd actually do it, mind you. I like my early Saturday mornings workplace-free).
This would need:
1. Access to the internet (not a problem)
2. A means of connecting to some service to place the call, preferably free, lest I cost the company $10 a month (Skype?)
3. An automated voice (already exists on the standard Access install package)
What do you think?
Edited 08/24/2009 - Spacing added. No text was changed.
Do the simplest thing that could possibly work. In this case, making phonecalls is hard, but sending emails is easy.
Most cellphone providers expose a phone's mailbox (something like 555-867-5309#cellphoneprovider.com) to the internet, allowing you to send an email to that address and have it show up on your phone as a text message.
You can use Skype in combination with VBA. It's actually not that complicated and you will find a couple of samples written in VBScript on the Skype website. I don't know whether it is possible to actually play an audio file, but you can send SMS easily:
'// Create a Skype4COM object:
Set oSkype = WScript.CreateObject("Skype4COM.Skype", "Skype_")
'// Start the Skype client:
If Not oSkype.Client.IsRunning Then oSkype.Client.Start() End If
'// Send SMS:
Set oSMS = oSkype.SendSms("+1234567890", "Hello!")
WScript.Sleep(60000)
'// Message event handler:
Public Sub Skype_SmsMessageStatusChanged(ByRef aSms, ByVal aStatus)
WScript.Echo ">Sms " & aSms.Id & " status " & aStatus & " " & oSkype.Convert.SmsMessageStatusToText(aStatus)
End Sub
'// Target event handler:
Public Sub Skype_SmsTargetStatusChanged(ByRef aTarget, ByVal aStatus)
WScript.Echo ">Sms " & aTarget.Message.Id & " target " & aTarget.Number & " status " & aStatus & " " & oSkype.Convert.SmsTargetStatusToText(aStatus)
End Sub
If you have a old dial up modem, then you could (in 'old VB6 days) dial via the modem programmatically, however I'm not sure if its possible in VBA. The next challange would be to get the audio down the line.
I would suggest that you butcher a headless earphone & microphone that connects to phones, you could then take a 3.5mm audio jack from your PC speaker output and connect this to the headless earphone/microphone set, unless there are cables that already do that (possibly).
Then it would be a simple matter of coding up Microsofts 'text to speech' engine.
Darknight
http://chandoo.org/wp/2009/02/05/twitter-from-excel/. Set up a twitter account that pings your phone and create twitters with this.
It's not as easy as the email idea, but you could be the first person to tweet from Excel for a reason other than novelty.
Another quite simple option is to send yourself a text message which is almost but not quite as easy to do as sending an email, but much easier to recieve. Companies such as clickatell.com provide cheap web based text services with good api's where once you are signed up all you need do is call a URL and you can send a text message.
Well worth a try.
Related
I have a typical “CDO gmail Email send” macro. It has worked reliably for a couple of years now.
I use a spare gmail account as the address it uses to send from. I want to share the macro with some people. So I will use a different gmail address as the sender.
I have some other spare gmail accounts and also some of the people have registered an account and given me the Username and Password to add to the macro as the sending address.
I have 10 accounts, seven of mine and three registered by others. All work in normal manual use. Three work with the macro, seven don’t.
As far as I can tell. all have identical settings. This includes the unsafe setting of On for “Less secure app access”.
The accounts have been registered at different times over the last two years.
One of the accounts that does not work was registered recently by someone having no previous accounts. One of the accounts that does work has been used almost daily for two years both manually and with the macro.
Two accounts were registered at the same time by two people in my family. They have been used normally/ manually to approximately the same extent for two years, but not previously with my macro. One account works in the macro, the other doesn’t.
These facts suggest to me that the non working accounts have not been blocked for suspected spamming. It seems random which accounts work and which don’t.
Below is a simplified version of the macro. (I can mostly use 465 or 25 as the smtpserverport. The results are almost always identical with either. Only very rarely, one will work whilst the other doesn’t. This seems to depend on the location from which the attempt is made).
The results I get are fairly consistent, including using the macro from different locations and different IP addresses.
I occasionally get security warnings for all accounts when I use the accounts from new locations but I always confirm that “it was me”. After taking this action, I never get security warnings again when using the account at that location. Immediately after such a warning, the account is temporarily blocked but the block is removed after I confirm “it was me”.
Three of the addresses almost always work with the macro. On the rare occasions that they don’t work, a second attempt is usually successful. (Those working addresses have been registered by me sometime in the last two years.)
Seven of the addresses never work with the macro. The error message at the .Send point is always the same:
-2147220975:
Die Nachricht konnte nicht an den SMTP-Server gesendet werden. Der Transportfehlercode lautet 0x80040217. Die Serverantwort lautet not available
An approximate English translation:
-2147220975:
The message could not be sent to the SMTP server. The transport error code is 0x80040217. The server response is not available
(To run the macro below, you must edit to give a real gmailAddress#gmail.com , a real gmailPassword , and real places to send the Email to at the .To and .cc)
Sub Run_gMail_Send_Simplified() ' Run this macro with a valid gmailAddress#gmail.com and gmailPassword and real places to send the Email to at the .To and .cc place
Call gMail_Send_Simplified("gmailAddress#gmail.com ", "gmailPassword")
End Sub
Sub gMail_Send_Simplified(ByVal UsrNme As String, ByVal PsWd As String) '
With CreateObject("CDO.Message") ' ' -------------------* with LCDCW Library ( Linking Configuration Data Cods Wollups) which are used and items configured for the Exchange at Microsoft's protocol therof
Dim LCD_CW As String: Let LCD_CW = "http://schemas.microsoft.com/cdo/configuration/"
.Configuration(LCD_CW & "smtpusessl") = True '
.Configuration(LCD_CW & "smtpauthenticate") = 1
' ' Sever info
.Configuration(LCD_CW & "smtpserver") = "smtp.gmail.com" '
' The mechanism to use to send messages.
.Configuration(LCD_CW & "sendusing") = 2
.Configuration(LCD_CW & "smtpserverport") = 25 ' or 465
.Configuration(LCD_CW & "sendusername") = UsrNme '
.Configuration(LCD_CW & "sendpassword") = PsWd
' Optional - How long to try ( End remote SMTP server configuration section )
.Configuration(LCD_CW & "smtpconnectiontimeout") = 30 '
' Intraction protocol is Set/ Updated
.Configuration.Fields.Update '
'End With ' -------------------* End with LCDCW Library ( Linking Configuration Data Cods Wollups) which are used and items configured for the Exchange at Microsoft's protocol therof
' Data to be sent
.To = "mrlotus123#somemail.com"
.cc = "billandben#someuveremail.com"
.BCC = ""
.from = """gMail_Send_Simplified"" <""" & UsrNme & """>"
.Subject = "Hello from " & UsrNme & " using gMail_Send_Simplified" '
.TextBody = "Hi" & vbNewLine & vbNewLine & "Testing. Please ignore this EMail"
' Do it
On Error GoTo Bed ' Intended to catch a possible predicted error in the next line when running the routine
.send
On Error GoTo 0
Debug.Print "Done " & Format(Now(), "hh mm") & " with Username: " & UsrNme & vbCr & vbLf
End With ' End With CreateObject("CDO.Message") (Rem 1 Library End =======#
Exit Sub
Bed:
Debug.Print "Fail " & Format(Now(), "hh mm") & " with Username: " & UsrNme & vbCr & vbLf & " " & Err.Number & ": " & Err.Description & vbCr & vbLf
End Sub
Any suggestions other than registering accounts and picking out the ones that work?
Is there some setting I may have missed?
Question also posted here:
https://support.google.com/mail/thread/17437986?hl=en&authuser=5
I have the problem solved so I am sharing the solution.
I have now improved the situation from 3 out of 10 accounts working to 11 out of 11 accounts working.
Here are the solution details for anyone else that has a similar problem. I would recommend starting with the solution _4) , as that is the quickest. If that does not solve the problem you will need to look at the others. The others may involve some laborious work.
_1 A strange thing in an old account, which was recently not working in my program and which I had definitely checked many times for Less Secure Apps On.
This account still had in the InBox many old typical Email Warnings from when I had attempted to do things such as logging in different places. ( Often this causes a temporary block, or resetting of Less Secure Apps Off , until you confirm something like “yes, that was me” ). All had been answered by me with “yes it was me”, at least I am 98% sure about that –they all been read, so it is very unlikely that I had ignored them
Never the less , I laboriously re read the Email warnings, and followed the link which almost always confirmed that I had answered, and any given link to the setting showed that it was indeed set to On.
There was one exception : the link showed that the Setting was off. Still looking at any other link or looking in that account settings showed it to be On. But I switched it on anyway, after which the account worked again in my program.
I note that all links in warnings are unique, as they contain information specific to the occurrence which sets off the warning. One explanation of the possible bug is that somehow an answer warning gets set back to unanswered, which blocks the account. The check for validation might be based for some reason on a dynamic process that has all the warnings in a chain, such that all must be answered with yes. This make sense since you can change your answer at a later date. The work around is to re answer all old warnings. In some old accounts I had trashed old Email warnings anymore, so I thought that I could not answer again answer, such that the account would remain blocked, despite showing that it isn’t. But strangely, in the trash folder all old warnings were there despite the default setting of only holding trash for 30 days… https://imgur.com/thNdDaV … very strange, in that screenshot there are entries going back to early 2018, despite the fact that it clearly states there that trash is deleted after 30 days. Other stuff that I trashed is gone.
In future , to be on the safe side, I will archive rather than delete warning Emails, or at least store the link given in it for checking and re setting Less Secure Apps.
_2 Setting suddenly showing (correctly) Off, allowing it to be set to On. Another old account, which was recently not working in my program and which I had definitely checked many times for Less Secure Apps On, suddenly showed Less Secure Apps Off. I then switched it On, and the account worked in my program. This may have been caused indirectly by some of the “cross wire” effects whilst I was looking at effects in other accounts. The moral of this one is not to rely on checking the setting just once, as later it might change for no apparent reason.
_ 3) I mentioned in the original post that my personal telephone cant be used any more to verify a new account, (gmail only allow a few uses for SMS confirmation – they deliberately do not say how many). Mostly that is still the case. On one random attempt during my experiments it worked. The new account then also worked in my program. – Hence I have 11 out of 11 now working, rather than 10 out of 10.
Similar conclusion again here: Don’t rely on the situation being static, some external thing may have some effect giving you a short period to do something that is generally not possible.
_4) Links going to wrong accounts. This mostly happens when I have other accounts open, but occasionally it also happens when I only have one account open.
As example: I get a valid warning based on some activity that I do on an account: https://imgur.com/VTAJOWc , I give it the OK, https://imgur.com/mKskkzx , and I then see a notice informing me that the Less Secure Apps has been set to Off, https://imgur.com/9bNePXf . So I follow the link for further info: https://imgur.com/LpGQYlj , and there after I follow a link to turn Less Secure Apps back on, https://imgur.com/WuMjPml . So far so good – note the account shown in the coloured ball top right is the correct one: https://imgur.com/yj09MsX
Now it gets interesting: I end up at the wrong account: https://imgur.com/T050wP4
That is easy to overlook. The solution here was to ignore links given and go directly to settings on the correct account, preferably soon after you get the warning. If you do not do that, then not only will you possibly not get to set the correct account, but also you possibly get another undesirable effect: sometimes the act of following the ( “crossed” ) link seemed to set off sporadic warnings and setting changes on other accounts !!!
This is all suggesting to me that there is some “cross wire type” bugs somewhere in Google.
_ 5 ) Rogue account getting other accounts warnings. This is related to _4) , but in particular one of my accounts not only got effected by following the “cross wired links” , but also frequently gets the warnings that should go to the other accounts. This happens even when I am not using that account anywhere. Once again this suggests some “cross wiring / leakage” caused by Google tracking what I , personally , am doing
_.______________
The short answer to what the problem was/is, is possibly that Less Safe App access was being blocked/ temporarily tuned Off, but for varied reasons it was not easy to switch it back On, since the obvious way to do that via settings was no use since it was often indicated as already On, and in some cases , just looking at it caused other account settings to change!!
I am slightly put off using gmail in my program. I have some concern that Google in its “spying” has got “cross wires / leakage” and it has grown into an uncontrollable monster that will probably break out of its server and appear in front of me and try kill me …… I actually registered the particular account discussed in _5) when I was away from home in India!!! ………… “…You are experiencing a car accident … The hell I am..” -- https://www.youtube.com/watch?v=L0Fw8TVYBKg
_.__________________-
I think we have all experienced at one time or another that adverts seem to pop up which obviously have got some “inside information” about us, which amongst other sources, may come from some Google “spying” on you . I use the word “spying” loosely – most likely we have agreed to it when agreeing to something without fully reading all the small print.
My recent experience is showing that I can follow links to change settings on one of my Google accounts, and then actually change settings on other accounts, even if I am not logged into these accounts. Further, I can change setting in one of my accounts, and it will cause changes in other accounts. I am not sure if that is supposed to happen. But it certainly does happen to me on some of my computers.
The common thing that is causing this cross wiring may be Google chrome browser. I should say finally that I am using a very old version often , in Vista. Possibly these issues do not arise if you only use a newer version..
Alan
(Running on Win 8.1)
The ultimate goal is the answer to this question:
Using VBA in Outlook 2013, how can I examine incoming RSS posts for contained keywords?
The details so far:
As per this page: http://www.slipstick.com/outlook/rules/outlooks-rules-and-alerts-run-a-script/ (first paragraph after the initial quote), it is possible to have a VBA script in Outlook 2013 to process PostItem arguments.
RSS feeds provide a PostItem argument, as in
Public Sub ScanRSSPost(Item As Outlook.PostItem)
...
End Sub
However, the rules wizard won't show this procedure.
Other procedures processing mails coming in and having a MailItem argument as in
Sub AddMailToOPQueue(oMail As Outlook.MailItem)
...
End Sub
are displayed as selectable scripts in the wizard and work as expected.
Is the lady simply wrong, or am I overlooking a setting of which I am not aware?
You cannot process incoming RSS items the way Application.NewMailEx lets you process new messages, but you can still use Items.ItemAdd event on the folder corresponding to a particular RSS feed.
I found that the claim in the quoted post simply does not work.
If you have the same question, here is a work-around:
(1) In Outlook, create a new rule: on receiving any feed (or the particular one you are interested in), forward it to your mail address (I created a dedicated one to keep things clean and uncluttered), and process no further rules.
(2) On the receiving mail address, create a new rule calling a script like this:
Sub AddMailToOPQueue(oMail As Outlook.MailItem)
...
End Sub
In the routine, the forwarded RSS posts' oMail.Body property will start with: blank, vbCrLf, blank, vbCrLf, "Feed: ", so to extract the feed in question, you can use something similar as:
If Left(sBody, 12) = " " & vbCrLf & " " & vbCrLf & "Feed: " Then
sFrom = Mid(sBody, 13)
sFrom = Left(sFrom, InStr(sFrom, vbCrLf) - 1)
'sFrom has the feed name now. The post's subject is in oMail.Subject.
...
End If
(3) In Outlook, create another rule for the addressee, on receiving items executing above script, which will be selectable in the wizard.
I currently have a SAPI voice implemented which works fine. I would like to know how do I handle Pause event in the engine when the application calls ISpVoice->Pause.
As near as I can tell, ISpVoice::Pause is implemented entirely in the SAPI layer and doesn't make any engine calls.
I'm trying to understand exactly what your end goal is, but I think I'll take a stab at answering this.
For voices, pause does the following according to MSDN:
ISpVoice::Pause pauses the voice at the nearest alert boundary and closes the output device, allowing access to pending speak requests from other voices.
Assuming you've used the speak call with SPF_AYSNC, you might also have to also set event interests and alert boundaries as seen here
Where the example shows handling bookmark alert boundaries
'Create a Normal Priority voice - male
Set objHIM = New SpVoice
Set objHIM.Voice = objHIM.GetVoices("gender=male").Item(0)
objHER.Speak "the priority of this voice is S V P alert"
objHIM.Speak "the priority of this voice is S V P normal"
objHIM.EventInterests = SVEBookmark 'Receive bookmark events only
objHIM.AlertBoundary = SVEPhoneme 'Let alert voices interrupt words
'Normal voice speaks text which generates events.
strSpeak = "This is text that contains bookmarks " _
& "for the purpose of generating events."
objHIM.Speak strSpeak, SVSFIsXML + SVSFlagsAsync
I have developed a small application and now i want to protect it.
I want to run it only on my own computer and i have developed it for myself.
How can i do that?
A. Don't publish it.
B. Hard-code your computer name in the code, and make the first thing the program does to be verifying that System.Environment.MachineName matches it.
You could always check the processor ID or motherboard serial number.
Private Function SystemSerialNumber() As String
' Get the Windows Management Instrumentation object.
Dim wmi As Object = GetObject("WinMgmts:")
' Get the "base boards" (mother boards).
Dim serial_numbers As String = ""
Dim mother_boards As Object = _
wmi.InstancesOf("Win32_BaseBoard")
For Each board As Object In mother_boards
serial_numbers &= ", " & board.SerialNumber
Next board
If serial_numbers.Length > 0 Then serial_numbers = _
serial_numbers.Substring(2)
Return serial_numbers
End Function
Private Function CpuId() As String
Dim computer As String = "."
Dim wmi As Object = GetObject("winmgmts:" & _
"{impersonationLevel=impersonate}!\\" & _
computer & "\root\cimv2")
Dim processors As Object = wmi.ExecQuery("Select * from " & _
"Win32_Processor")
Dim cpu_ids As String = ""
For Each cpu As Object In processors
cpu_ids = cpu_ids & ", " & cpu.ProcessorId
Next cpu
If cpu_ids.Length > 0 Then cpu_ids = _
cpu_ids.Substring(2)
Return cpu_ids
End Function
Was taken from where: http://www.vb-helper.com/howto_net_get_cpu_serial_number_id.html
Here's a question by Jim to convert this for Option Strict.
It really depends on who is the "enemy".
If you wish to protect it from your greedy, non-cracker, friends, then you can simply have the application run only if a certain password is found in the registry (using a cryptographically secure hash function), or use the MachineName as Jay suggested.
But if you're thinking of protecting it from serious "enemies", do notice: It has been mathematically proven that as long as the hardware is insecure, any software running on it is inherently insecure. That means that every piece of software is crackable, any protection mechanism is bypassable (even secured-hardware devices such as Alladin's Finjan USB product key, since the rest of the hardware is insecure).
Since most (if not all) of today's hardware is insecure, you simply cannot get 100% security in a software.
In between, there are lots of security solutions for licensing and copy-protection. It all comes down to who is the enemy and what is the threat.
No matter how hard you try, if someone really want to run it on another computer, they will.
All need to do is reverse engineer your protection to
remove it
play with it
Another option might be to have your program ask the USER a question that has a derived answer. Here's a brain dead example....
Your Program: "What time is it now?"
You Enter: (TheYear + 10 - theDay + 11) Mod 13
In this way its actually ONLY YOU that can run the program instead of it being MACHINE dependent.
I have made things like this in VB DOS.
I either made a non-deletable file that is key to a specific machine with a code inside, and/or read the .pwl files and have several checks, that are only on your machine. The non-editable file is made with extended character sets like char 233 so when a person tries to look at it, it will open a blank copy (edit) (write.ex), so data cannot be read and it cannot be edited moved or deleted.
It needs to be certain characters; I am not sure if every charter between 128 and 255 will work it, some extended characters work to do this some will not, also it can be defeated, but it will keep some people out,
But it can be read or checked in a program environment. Nothing is totally secure, this is some of the things I mess with.
Note: the file will be very hard to delete, maybe make a test directory to test this.
I hope this is OK I am not very good at conveying info to people; I have programmed since 1982.
Another idea ... I wrote a program that cannot be run directly, it is only ran by an external file, so you could add in a password entry section to it and encrypt password so it cannot be read very easily ,I made an executable version of a vb program to test. it writes in to slack space a character so if the program sees that value it will not run, BUT the runner program has a different character, and it changes it to that character ,and the program is designed to only let in if the character is the proper one ,made only by the runner , then when it enters it changes it back so it is not left open , I have made this sorta thing, and it does work, there is always a way to defeat any protection , the goal is to slow them down or discourage them from running or using your program if you do not want them to.I may include examples at a later date.
We have a lot of customized spreadsheet solutions that are being used and we want some programmatic way of keeping track of them. Obviously since they are spreadsheets, people can save them locally, rename them, etc so we need a solution that can account for that.
Some ideas are:
On spreadsheet open, handle the OnOpen event and write a message to a database for tracking
the issues with this are where do we store database details. If the database is down, we dont want the spreadsheet to crash, etc
has anyone come up with a good spreadsheet inventory management solution that handles all the issues above.
I don't understand the problem you're trying to solve here: you don't need spreadsheet usage logging as an end-result, something is causing pain and this is what you've devised to try to fix it.
If you need seriously reliable logging of all spreadsheet usage, then I don't think this is going to work. If you need mostly reliable logging, then just use a database and don't worry about the (rare) occasions that the database is down. On Error Resume Next should be enough to ensure the spreadsheet continues in that event.
That said, I'd be more inclined to go for a web-based solution: that way you don't have to get involved with ensuring everyone has the necessary database drivers, working connection strings and other horridness.
Some more awkward questions that are making me think that you may need another approach:
How are you going to deploy changes to your logging solution?
Do your users have control over their macro security level? Or the ability to write and edit macros? Could they therefore (innocently or otherwise) disable logging?
Can the users operate offline? What happens then?
Have the excel spreadsheet make a request out to a web server.
Add msinet.ocx to your toolbox and create a form with the Inet control. Add the ocx by right clicking somewhere in the toolbox area.
Then you can set the location of the Inet control somewhere you can handle that the spreadsheet was opened.
Although you may need logging in the short term, the long term solution should be to bring your spreadsheets under control. You should gather the "definitive" copy of the spreadsheets, and move them to a file share, where they will all be protected - users will be able to change the data in them, but will be unable to change the formulas.
If you need a more controlled collaboration solution, then you should look into using SharePoint, possibly the MOSS version which has Excel Services on it.
You might also need to explore how the spreadsheets are being used. Perhaps they are being used instead of someone writing a program, and in some cases, it may be time to do that.
Lastly, you don't want to track spreadsheet usage - you don't care if someone creates a spreadsheet to track their kid's soccer team scores. It's particular spreadsheets you're interested in. The logging may help you track that down to start with, but that's all it can help you with.
I like the suggestions being made so far and what you wrote. I personally like to keep things simple so here's my humble suggestion. It sounds like you have a lot of templates you may be managing and with excel things get messy quick and it's hard to know that formulas are not being tampered with. With that in mind I'd forget any database change management solution, instead:
Create a share drive folder that's set to read only and accessible by everyone in the company
You can create a sub folder structure that makes sense by team, department, location, whatever works
Store the latest copies of the excel templates in the folders
I'd also suggest locking the templates that have critical calculations in them
--> Try to leave it as open as you can so they can be customized where they need be but at your discretion
You may also consider setting up a version control repository that manages the changes to this folder structure. Look into version control with a simple interface like tortoiseSVN so you can track what changes were made and when. The standard share drive back ups are a life saver but I'd still supplement with a version control system (just makes things a little easier). Here's a couple of links to help you get started, you can try subversion locally and see what you think:
Instructions to setup Subversion on Windows
Tortoise Client to interact with Subversion
Also note, IF you chose to implement some kind of database connection for a spreadsheet to perform logging on a database server as has already been noted you can use "on error resume next". Here's what you can do:
After resume next attempt to open the connection to the DB
You can choose to handle the error then with an if statement such as:
if err.number = 3024 then
msgbox "Database file not found, check network connection and retry"
exit
end if
Here's a link to look up additional error codes for trapping in similar fashion:
Error Trapping in VBA
I do something very similar to this to check the current version of the Excel application. You could just as easily use this same code to make a web-request to a server that will log 'hits'. Here's my code:
In ThisWorkbook:
Option Explicit
Private Sub Workbook_Open()
Updater.CheckVersion
End Sub
Elsewhere (in a module called Updater)
Option Explicit
Const VersionURL = "http://yourServer/CurrentVersion.txt"
Const ChangesURL = "http://yourServer/Changelog.txt"
Const LatestVersionURL = "http://yourServer/YourTool.xlsm"
#If VBA7 Then
Private Declare PtrSafe Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
(ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
#Else
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
(ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
#End If
Public Sub CheckVersion()
On Error GoTo fail
Application.StatusBar = "Checking for newer version..."
Dim ThisVersion As String, LatestVersion As String, VersionChanges As String
ThisVersion = Range("CurrentVersion").Text
If ThisVersion = vbNullString Then GoTo fail
LatestVersion = FetchFile(VersionURL, , True)
VersionChanges = FetchFile(ChangesURL, , True)
If LatestVersion = vbNullString Then
Application.StatusBar = "Version Check Failed!"
Exit Sub
Else
If LatestVersion = ThisVersion Then
Application.StatusBar = "Version Check: You are running the latest version!"
Else
Application.StatusBar = "Version Check: This tool is out of date!"
If (MsgBox("You are not running the latest version of this tool. Your version is " & _
ThisVersion & ", and the latest version is " & LatestVersion & vbNewLine & _
vbNewLine & "Changes: " & VersionChanges & vbNewLine & _
vbNewLine & "Click OK to visit the latest version download link.", vbOKCancel, _
"Tool Out of Date Notification") = vbOK) Then
ShellExecute 0, vbNullString, LatestVersionURL, vbNullString, vbNullString, vbNormalFocus
End If
End If
End If
Exit Sub
fail:
On Error Resume Next
Application.StatusBar = "Version Check Failed (" & Err.Description & ")"
End Sub
As you can see, error handling is in place to make sure that if the URL is unavailable, the app doesn't crash, it just writes a message to the user in the status bar.
Note that if you don't want to set up a web service that does this, you could try to have the spreadsheet write to a database - you could still re-use a lot of this code, but not as much of it.
Your idea is good. Database availability is usually higher than the availability of the users' laptop. And there is a kind of primitive error (exception) handling in VBA, so they won't necessarily see freaking error messages.
Yes, you have a loss. Any uses of the sheet saved offline when the user is not on your network - will be missing from the database. But I don't think that there's a 100% foolproof solution for this.
Try to search for a Financial Times article like "Excel - a tool that is too ad hoc and open for errors". Even the title says it all.
write to the db, if the write fails, catch the error and send an e-mail to someone that can manually increment the count when the database is back up.
You could do a file-based approach with any of several file integrity monitoring solutions. Samhain is one free open source example. That would allow your employees to access their spreadsheets without interference, but would report when new spreadsheets are discovered or when their timestamps or hash values change. It would also detect changes made while the developer was off-line (on their laptops, for example) once they've reconnected to the network.