Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old December 21st, 2004, 02:10 PM
Registered User
 
Join Date: Nov 2003
Location: , , .
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default Include Library Reference at RunTime

The easy way to include a library reference is to Alt-F11 to VBA, then click Tools>References, and then pick one.

But I'd like sometimes to use a reference to the Office 11.0 Library and sometimes not.

Is there a way to add that reference programmatically when the xls opens ?

Thanks, Stoney
Reply With Quote
  #2 (permalink)  
Old December 22nd, 2004, 06:53 AM
Authorized User
 
Join Date: Jun 2003
Location: , , United Kingdom.
Posts: 59
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I don't quite understand why you'd want to refernce/unreference the Office library from your VBA project, however the following are (untested) procedures to add and remove the references

Code:
Public Sub addRefToOffice()
  On Error Resume Next
  Application.VBE.ActiveVBProject.References.AddFromFile "C:\Program Files\Microsoft Office\Office11\MSO11.DLL"
End Sub

Public Sub removeRefToOffice()
  Dim ref As Object
  On Error Resume Next
  Set ref = Application.VBE.ActiveVBProject.References("Office")
  Application.VBE.ActiveVBProject.References.Remove ref
End Sub
Hope that gets you started
Reply With Quote
  #3 (permalink)  
Old December 22nd, 2004, 12:48 PM
Registered User
 
Join Date: Nov 2003
Location: , , .
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you !! That's exactly what I needed.
Reply With Quote
  #4 (permalink)  
Old December 23rd, 2004, 12:37 PM
Registered User
 
Join Date: Nov 2003
Location: , , .
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Here's what happened and why I think I need to do this: this Excel project was developed and is on-going in Excel 2003 & Windows XP. It just surfaced that some users are in Excel 2000 and Windows 2000 - and will not upgrade soon.

So my thought, in an effort to avoid maintaining two developemnt projects, was to determine if the user was one of those 2000 guys, then add the 2000 references and remove the 2003 references.

How does that sound?
Reply With Quote
  #5 (permalink)  
Old January 14th, 2005, 03:40 AM
Authorized User
 
Join Date: Jan 2005
Location: , , .
Posts: 37
Thanks: 0
Thanked 0 Times in 0 Posts
Default

This is giving me great knowledge.

Thank you very much

Amjad

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to include static library in c# nitesh kumar C# 2005 0 July 25th, 2008 12:45 AM
runtime automation error library not registered deco Pro VB 6 2 July 31st, 2007 08:09 AM
Code Library Reference ClaudiaCastle Access VBA 6 February 20th, 2007 12:23 PM
Add a reference on Runtime anandham Pro VB 6 3 September 18th, 2006 09:16 AM
Standard Library Reference resource markcholland BOOK: Professional C++ 0 March 17th, 2006 02:31 PM



All times are GMT -4. The time now is 01:47 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.