Friday, September 15, 2006

BeTTR Compatibility

I have installed the Beta Two Technical Refresh, and this morning fired up my contacts database in Access2007.

I am suddenly confronted with problems.

In fairness I must confess that my Access VBA skills are not as good as yours.

There may well be serious deficiencies in my code that have escaped notice until now, but today I am receiving warnings that were not in effect yesterday. The difference is that today I am running not the Beta2, but the patched version - BTTR.

For over a year (Access 2000 and on) I have used a routine that updates various date fields when I post a follow-up date into the future. The background receives a colour showing whether the date is in the future or the past.

Today Access 2007 tells me that it can't find the field, but clearly the View Immediate tells me that it can find the field.

The problem possibly lies in the "#Name?" value that has crept in there. Perhaps earlier versions of Access didn't mind that value, or perhaps earlier versions didn't produce that value. Please see "my Access VBA skills" above.

In desperation, I resort to On Error Resume Next.

Desperation because I'm scheduled to make telephone calls right now, not learn VBA programming (see? I'm no different from you; I have a job to do).

I hate On Error with a passion. To me it indicates one of three things:

Lack of professionalism in the programmer (that is my case here; I'm not yet prepared to work out why I'm getting a "Name?" value).

Lack of planning in the programmer (that is my case here; I had not planned for an event such as faulty input data, or whatever it is that triggers this data).

Poor design in the product. I know that a good workman never blames his tools, but VBA provides no intrinsic function for testing a file's existence, or whether a project is password-protected, so we all resort to the trick of trying to do something and returning a trapped error if it fails.

Then it crops up again.

This time on a null field.

I'll swear I had no problem with this yesterday.

I could be wrong.

You knew this was going to happen.

On Error resume Next and a cheap'n'nasty Word macro, and we are back in business.

Baling Twine. We need more baling twine.

Sunday, September 10, 2006

Version Compatibility

I have been engaged in a mild debate over at Woody's Lounge regarding the various versions of Word. My incoming task was to obtain the most recently used file list for each and every version of Word from Office 2007 through Office 2007.

MRUse in its initial incarnation made use of the application object, its Recent Files list. That approach does not work when several versions of the application exist.

Dim xlApp As Excel.Application
Set xlApp = CreateObject("Excel.Application") ' gets me 9.0, but I want all!
Dim lng As Long
For lng = 1 To xlApp.RecentFiles.Count
Dim strFullName As String
strFullName = xlApp.RecentFiles(lng).Path

The code snippet above will always grab Excel 9.0's recent files if Excel 9.0 was the latest version (of 8.0, 9.0, 10.0, 11.0 and 12.0) to be loaded and used.

I need dive into the registry now, and that is what I do.

Dim lng As Long
For lng = lngLow To lngHigh
Dim strValue As String
strValue = strWeTrim(QueryValue(HKEY_CURRENT_USER, _
strKey, strValuePrefix & Trim(Str(lng))))

The debate does not quite rage, but if it did, it would rage over the issue of whether or not one can successfully run four versions of Office under a single operating system (Windows XP) on a single partition single-boot system.

Yes you can! I am doing just that.

I have a 2GB RAM 100GB drive laptop with Windows XP professional, and licensed copies of Office 97, Office 2000, Office 2003 and Office 2007 beta, installed in that sequence.

I can load a copy of each version of Word and thus have four versions of Word running on the machine.

Each version of Word uses the same default file locations for documents, Startup folder and so on, so each version of word exhibits and permits use of the applications (Under, Trail, Indxr and so on) that I have developed in Word VBA for end-users of Word.

The only annoyances I have spotted so far are:

From time to time Office 2000 or Office 2003 whips out its flashlight and looks for something. I think it thinks it is "repairing" the registry because a different version of Office has just "repaired" it back to its own devices.

From time to time my Toolbars Best Fit macro doesn't. I will look into this. I suspect it will be found as a programming error on my part.

Apart from that, I can't see any major conflict that faces me, as a developer of VBA applications in multiple versions of Office.