Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reference to VB project

Status
Not open for further replies.

caerdydd

Programmer
Mar 2, 2004
35
GB
Hi guys
Created a link via a button from an in-house application to excel which works fine. But for it to work excel must be referenced from within the application otherwise it fails.
Doing this manually is OK just select the project. But we have numerous PCs to test on so wanted to do this programmatically. Thus, code i thought would work is -

Application.VBE.ActiveVBProject.References.AddFromFile _
"C:\Program Files\Microsoft Office\Office\EXCEL8.OLB"

But errors out with the message of name conflicts with existing module or project. How do i get round this?
Thanks for the help.
Cheers
 
Have you tried leaving it not referenced and then running that code?
 
You may consider late binding instead of early binding.
Replace the the lines like this:
Dim objXL As Excel.Application
Set objXL = New Excel.Application
By something like this:
Dim objXL as Object
Set objXL = CreateObject("Excel.Application")
So you don't have reto reference the microsoft excel object library and you don't worry the excel version.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thank you PHV. I have it working magnificently now.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top