views:

507

answers:

4

I made a VBA project based on Excel and Access. When I copied to other computers, some methods (left, right, etc) or controls (ComboBox) sometimes disabled. I had to rebuild in that computer. But sometimes it's OK. Why? Is that because of licence issues?

+1  A: 

Not because on licensing. A lot of factors could be, but I could nail it down to: Depending on the Office SP version differences on multiple computers, it might give you headaches. Also check the Office Web Components version of each. Your Options & Add-in on Office might give you some clues.

Codex73
What connection do the Office Web Components have to MS Access? This sounds like a typical references problem to me.
David-W-Fenton
No connection directly, but he seems to be using OWC inside his VB APP. Most likely he is apparently as his trouble bounces from client scenarios.
Codex73
+2  A: 

Check the references on the computer that it is failing on (via tools/references menu item in the VBA editor). Different platforms can have different sets of DLLs installed and you will get some misleading errors from excel if there is a reference that is marked "MISSING".

This is discussed in this question

Cannonade
+1  A: 

It is important to check security and permissions on the computer that you are having problems on. Users must have full permissions on both the fron-end and back-end folders. Macros will not run if security settings do not permit them. You may wish to read:

Self certification and digital signatures

General information on security principals for Office code and macro security

Trusted location defaults for Office 2003

Macro security in Office 2003

For the most part, late binding will solve problems with references in VBA, unless you have some unusual references. Most problems are caused by differences in library versions that can be overcome with late binding. With VBA, it is often recommended that you develop with early binding but release with late binding. The main disadvantage of late binding is changing built-in constants to values (speed is no longer the issue it used to be.)

Remou
The only exception for the late binding is if you're using an embedded control, which can't be used with late binding at all. This is one reason many developers avoid non-native controls in Access.
David-W-Fenton
+2  A: 

This is a version difference/missing reference issue. Sometimes it gives you the error on the correct function, and sometimes on completely unrelated functions.

If you are deploying to different versions of Excel you can use late binding instead of early binding to relieve this problem. When you are developing you can use stuff like

Dim x As Excel.Application
x = New Excel.Application

But for deployment you can change it to the following and then remove the reference altogether.

Dim x As Object
x = CreateObject("Excel.Application")
Will Rickards