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
| 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 February 10th, 2005, 02:17 PM
Authorized User
 
Join Date: Jun 2003
Location: , , .
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default Addin Project References

Hi --

    How can I check programmatically that a workbook has a project reference to an AddIn and if it doesn't, then add it.

    I know how to do it manually using the Tools\Reference menu option in the VBA editor, but I don't know how to let the workbook do it.

Thanks,

Barry




Reply With Quote
  #2 (permalink)  
Old February 10th, 2005, 08:11 PM
Authorized User
 
Join Date: Jun 2003
Location: , , United Kingdom.
Posts: 59
Thanks: 0
Thanked 0 Times in 0 Posts
Default

you want to do something like (untested):

Code:
Public Sub buildRefs()
  Call assertRef("C:\Program Files\Microsoft Office\Office11\XLStart\Book1.xla")
  Call assertRef("C:\windows\system32\msxml2.dll")
End Sub

Private Sub assertRef(fileSpec As String)
  If Not addRef(fileSpec) Then
    debug.print "Reference to " & fileSpec & " was unsuccessful"
  End If
End Sub

Private Function addRef(fileSpec As String) As boolean
  On Error Resume Next
  If Not doesRefExist(fileSpec) Then
    activeWorkbook.VBProject.References.AddFromFile fileSpec
  End If
  addRef = (Err.Number = 0)
End Function

private Function doesRefExist(fileSpec As string) As Boolean
  Dim ref As Object
  For Each ref In ThisWorkbook.VBProject.References
    If StrComp(ref.FullPath, fileSpec, vbTextCompare) = 0 Then
      doesRefExist = True
      Exit For
    End If
  Next
End Function
ie. running the "buildRefs" procedure adds references to an XLA addin, and a DLL. Is this what you mean?
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
References and VB ’05 Web Project BrianWren Visual Basic 2005 Basics 0 December 15th, 2006 04:23 PM
Legacy references in a duplicate project JohnS VS.NET 2002/2003 0 March 10th, 2005 02:08 PM
Addin narendrapawar VB How-To 0 January 5th, 2005 09:30 AM
Adding Web References to a project.... vb_developer C# 0 September 5th, 2004 01:32 AM
closing a project is a problem inside an addin... gbianchi Pro VB 6 2 September 1st, 2003 01:46 PM



All times are GMT -4. The time now is 03:23 AM.


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