To declare the library when using a function?

P

Pablo Cardellino

I have a template with quite much code. It runs perfectly on my
computer, with Office 2003. However, in other PCs, also with Office
2003, it triggers an error: the VBA interpreter doesn't find the library
refering to Trim() and other string functions. If I code

String.Trim("noonoonoono")

the script runs fine. The same with Environ("nonononno"), which requires
to be coded

Interaction.Environ("nonnonnoo")

to run properly.

Is there any kind of declaration that allow to use just
Trim("nonnnononoon") r Environ("nonononoono")?


Best regards,
 
C

Cindy M.

Hi Pablo,

The functions you mention are part of the VBA library, shared by all Office
applications. If you look in Tools/References on your machine you should
see a checkmark next to the entry "Visual Basic for Applications".

Normally, I'd expect that to be automatically available on any machine with
Office installed that also has VBA/macro support installed. Once, many
years ago, I did run into the same problem you're seeing, but it wasn't
with Word, it was with Access. And apparently the problem can crop up more
regularly with Access.

The reason (as best I can recall four or five years down the line) was due
to references to third-party DLLs required in the database application I
was loading that were not installed on the target machine. So when the
database application tried to compile the VBA code, it couldn't do so
properly and showed this same message you're seeing for any functions
contained in the VBA DLL. I never found out *why* VBA does this, just that
removing those references from the database project (so that the compiler
didn't try to reference them) solved the problem well enough for me to do
the work I had to do.
I have a template with quite much code. It runs perfectly on my
computer, with Office 2003. However, in other PCs, also with Office
2003, it triggers an error: the VBA interpreter doesn't find the library
refering to Trim() and other string functions. If I code

String.Trim("noonoonoono")

the script runs fine. The same with Environ("nonononno"), which requires
to be coded

Interaction.Environ("nonnonnoo")

to run properly.

Is there any kind of declaration that allow to use just
Trim("nonnnononoon") r Environ("nonononoono")?


Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 
T

Tony Jollans

Cindy is correct that this due to a missing reference, but not the VBA
library itself, which should be available (and not removable). When you try
to use a function that is not fully qualified, VBA wants to look at all
references to resolve the qualification and if there is any missing one at
all, it gets stuck. In the VBE go to Toools > References and in the dialog
you should see one (or more) references flagged as "MISSING"; take whatever
action you need to to resolve the problem (remove them, change them, perhaps
a change of version - depends on your requirements) and all should be well
with the rest of the world.
 
P

Pablo Cardellino

Hi Tony, hi Cindy,

On my PC everything run OK. The problem is that on some other PCs (to
which I have no physical access) this problem appears, and I cannot ask
the user to open the VBA environment for solving the problem. I need the
application to run properly without requiring any expert handling by the
user. Could I solve this through VBA?

--
Pablo Cardellino
Florianópolis, SC
Brazil

Tony Jollans escribió:
 
T

Tony Jollans

That will depend on what reference is missing and whether or not it is
available on the other machine. You might be able to overcome the problem by
removing the references and using late binding.
 
K

Karl E. Peterson

Tony said:
That will depend on what reference is missing and whether or not it is
available on the other machine. You might be able to overcome the problem by
removing the references and using late binding.

Based on Tony's response, I'm inclined to ask what other libraries your project
references? Are there any that are <ahem> non-standard in any sort of way?
 
P

Pablo Cardellino

Well, well, I am not much more than a begginer, I guess, so there are so
much things I need to learn...

When I begin to develope this project I referenced some libraries, just
for thinking they could be useful, and I forget of this fact. The
"detail" is that I didn't know that those references were going to be
saved into the project. I thought that I was just activating tools
within the developing environment, not for production too. In short, I
had some references (I don't thing they were non-standard ones, since
they were installed with the Office and the VBA itself: i didn't add
anythig by myself) that my project didn't use, so I undeclared them and
I went to a cyber-café where I found a PC that presented the problem,
and voilá: everything runned perfectly.

So, I has just to thank you all a lot.

Best regards,

--
Pablo Cardellino
Florianópolis, SC
Brazil


Karl E. Peterson escribió:
 
K

Karl E. Peterson

Pablo said:
Well, well, I am not much more than a begginer, I guess, so there are so
much things I need to learn...

When I begin to develope this project I referenced some libraries, just
for thinking they could be useful, and I forget of this fact. The
"detail" is that I didn't know that those references were going to be
saved into the project. I thought that I was just activating tools
within the developing environment, not for production too. In short, I
had some references (I don't thing they were non-standard ones, since
they were installed with the Office and the VBA itself: i didn't add
anythig by myself) that my project didn't use, so I undeclared them and
I went to a cyber-café where I found a PC that presented the problem,
and voilá: everything runned perfectly.

Good to hear! Non-standard can be pretty much anything that isn't turned on by
default, as you found out the hard way. It's odd that ones provided with Office
were causing problems, but if the other machines didn't have exactly matching
installs, I can see that being the case. Anyway, glad you got it worked out.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top