VBA/VB6 Collection Type Mismatch

J

Jake Stevenson

I call a VBA function in a Word template from a VB6 application,
passing a Collection as an argument to the function. This works well
in most cases, except a couple of rogue machines. On just one or two
machines, I get a "Type Mismatch" error when attempting to call the
function.

It looks to me like the VBA collection object on these machines does
not match the VB6 collection object. Is this possible? Can anyone
suggest a way to fix the problem?
 
P

Perry

passing a Collection as an argument to the function. This works well
in most cases, except a couple of rogue machines.

Find the differences in the machines where things work, and those where yr
program fails.
There's has to be a difference.
Upgrade/correct the failing machines, and y're set.

-------------------------------------
Krgrds.
Perry

System parameters:
POS: WinXP x64
MSO: MSOffice System
DEV: VS7 (dotnet)
-------------------------------------
 
C

Cindy M -WordMVP-

Hi Jake,

It would also help, when you ask a question, to tell use the version of
WORD involved in the problem... If, for example, this were Word 97 in
combination with VB6 then there could very well be a problem, as Word
97 uses VB5, not 6.
I call a VBA function in a Word template from a VB6 application,
passing a Collection as an argument to the function. This works well
in most cases, except a couple of rogue machines. On just one or two
machines, I get a "Type Mismatch" error when attempting to call the
function.

It looks to me like the VBA collection object on these machines does
not match the VB6 collection object. Is this possible? Can anyone
suggest a way to fix the problem?

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
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 :)
 
J

Jake Stevenson

Cindy,

Yes, that was foolish of me to forget that bit of information. The
machine in question has Word 2000 installed.

It is a single machine on a client's system, I do not have direct
access to the machine or a great deal of information about it
immediately available. I wonder if perhaps they upgraded it from
Office97 and did not update all of the VBA bits in there.
 
H

Howard Kaikow

how are you building the vb 6 app?

if you built the vb 6 app using a more recent word vesion than on the other
system, you might have run-time problems.
 
C

Cindy M -WordMVP-

Hi Jake,
Yes, that was foolish of me to forget that bit of information. The
machine in question has Word 2000 installed.

It is a single machine on a client's system, I do not have direct
access to the machine or a great deal of information about it
immediately available. I wonder if perhaps they upgraded it from
Office97 and did not update all of the VBA bits in there.
Might be best if you posted the code causing the problem, so that we
can see what objects you're trying to use?

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
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 :)
 
J

Jake Stevenson

I can't post the whole code, but it's pretty simple. I'm using a
collection as an argument when calling a subroutine in the template.
So in VB6 I do something like:

objDocument.Pass_References cCollection, lLong, iInt

And in the template :

Public Sub Pass_References(cCollection as Collection, lLong as Long,
iInt as Integer)
'Do stuff with these.
End Sub

I build the VB6 application referencing "Microsoft Word 8.0 Object
Library" to try and ensure maximum compatibility. We only claim to
support Word2000 or better.

My guess is that the client managed to "build their own" Word
installation using their own imaging/SMS software or something similar,
and upgraded from Office97 to 2000. I'd bet they missed something in
the upgrade there. Luckily, its only one of their machines (out of a
dozen or so) which has a problem. We may be able to convince them to
re-install Office from scratch.
 
H

Howard Kaikow

Jake Stevenson said:
I build the VB6 application referencing "Microsoft Word 8.0 Object
Library" to try and ensure maximum compatibility. We only claim to
support Word2000 or better.

If you built the exe/dll using the Office 97 libraries, then the code should
run, subject to odd bugs in Office, using later versions of Office.

If you built yje code with Office 97, then you need to test with all later
versions of Office.

There's always the chance thgat your custome rhas some app installed that
interferes.
No way to tell without running in the same environment.
My guess is that the client managed to "build their own" Word
installation using their own imaging/SMS software or something similar,
and upgraded from Office97 to 2000. I'd bet they missed something in
the upgrade there. Luckily, its only one of their machines (out of a
dozen or so) which has a problem. We may be able to convince them to
re-install Office from scratch.

I would not ask them to re-install Office.
Instead, write a simple example that tests the collection object in Word 97.
See if that works.
 

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