Wrox Programmer Forums
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 17th, 2005, 11:29 AM
Registered User
 
Join Date: Feb 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default VBA References

When I add a reference in VBA by checking the appropriate box under Tools/References, is there a way to tell Excel to "remember" that this reference is checked for all new worksheets the next time I open Excel?

Thanks
 
Old February 17th, 2005, 11:38 AM
Authorized User
 
Join Date: Jun 2003
Posts: 59
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Don't think you can do this out-of-the-box.

You could however create an Excel addin (.XLA) which exposes the Excel Application's NewWorkbook event, ie. create a class in your addin that reads something like:

Code:
public WithEvents ExcelApp As Excel.Application
Private Sub ExcelApp_NewWorkbook(ByVal Wb As Workbook)
  Wb.VBProject.References.AddFromFile "C:\myComponent.XLA"
End Sub
Then in the addin's Workbook_Open event, or the AddinInstall event, whatever is appropriate, initialise the ExcelApp variable with the current instance of the application, ie.

Code:
Private mAppSinkClass As clsAppSink
Private Sub Workbook_Open()
  set mAppSinkClass = New clsAppSink
  et mAppSinkClass.ExcelApp = Excel.Application
End Sub
 
Old February 18th, 2005, 09:33 AM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 180
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Open the VB Editor. Select the Personal.xls object. (If it does not exists then go back to excel and record a macro stating to save it in the personal macro workbook)

In the VB Editor, open a page of code in a module sitting in the personnal workbook. In the references add the reference you want. Still in the VBEditor, click the save icon to save the personal macro book. Close Excel and reopen. The Reference should still be there. Because you are associating the reference to the Personnal Macro book the reference is opened each time you open Excel.

Cheers

Matthew






Similar Threads
Thread Thread Starter Forum Replies Last Post
Conflicting Libraries in VBA References echovue Access VBA 1 July 11th, 2006 10:56 AM
VBA References muki Beginning VB 6 3 May 16th, 2006 03:32 AM
references emmgus XSLT 2 August 4th, 2005 01:20 PM
Access VBA References LoriBee Access VBA 1 September 17th, 2003 04:54 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.