VBA - Error when running DOCXM template on another computer

dragon-goddess1990

New Member
Joined
May 18, 2011
Messages
25
Program: Word 2010

I have created a letter template with a userform.

I send it to another user and he gets the message: 'Compile Error: Cant find project or library'

It seems to reference the following line:

UserName1 =
Application.UserName
Dim (fileList {} As String.....etc

(it only highlights the 'UserName 1 = ' bit of code not the rest of the line)

UserName1 is a variable name....and i have tried it with another name incase it was referencing a function or something.

Works fine on mine but on no others....

Please help :)
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
Chances are, if the user looks in VBE Tools > References, one will appear as MISSING because of a version difference between the computers. What references do you have set?

Changing your code to use late binding and removing the references you have set may solve the problem. E.g.,

Code:
Dim appWd as Word.Application
Set appWd = New Word.Application
would change to

Code:
Dim appWd as Object
Set appWd = CreateObject("Word.Application")

You may have to define some constants in your code to replace those that are defined in libraries you have removed -- so it's VERY important to use Option Explicit.

I don't do much Word automation, and so may be of limited help.
 
Upvote 0
Hi there

Thank you for replying!!

Hmm I will check the VBE Tools > References and see what it says. I admit they are using Word 2007 but didnt think it would be of much significance.

As for the code bit I havent ever heard of late binding and what the code is - could you dumb it down for me please?

Regards

Amy
 
Upvote 0
Amy

You don't need to use late-binding or early-binding unless you are automating Word from another application, eg Excel.

Are you doing that?
 
Upvote 0
As for the code bit I havent ever heard of late binding and what the code is - could you dumb it down for me please?
Since it would be your code that gets modified, perhaps it would be better if you posted that.
 
Upvote 0
Nope only VBA userform in the template.

So check the VBE Tools > References - I did wonder if it was to do with a userform control I used (I.e calendar date control) but I assumed not as it was referencing the above bit of code. I also wondered if Application.username existed in 2007

Amy
 
Upvote 0
Amy

Which computer are you checking the references on?

Yours or the one the problem appeared on?
 
Upvote 0
Application.UserName does indeed exist, but it's the name set by a user under (Office Program) > Options, and so can readily be changed.

I suspect you would want instead Environ("username")
 
Upvote 0
Brilliant - thank you.

2 were missing:
1 - MISSING: Microsoft Windows Common Controls-2 6.0
2 - MISSING: Microsoft Office Project 12.0 Calendar Control

I checked my template on my machine and the 1st one was off anyway....and couldnt find the second.

Thank you for your help

Maybe if I recreate the template it might ignore that I tried the controls before (probably client side though)
 
Upvote 0

Forum statistics

Threads
1,225,626
Messages
6,186,090
Members
453,337
Latest member
fiaz ahmad

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top