Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.office.developer.automation,microsoft.public.office.developer.vba
external usenet poster
 
Posts: 4
Default Adding reference in code

Hello all,
Is there a way to programatically add a reference to a dll or .xla file from
an Excel workbook? (i.e. ToolsReferences from the VB Editor) .

Thanks,
Andrew


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Adding reference in code

To add an XLA file:

AddIns("ODBC Add-in").Installed = True

ODBC Add-in is added; setting to False removes it.

If a Win32 DLL, then something like:

Declare Function CopyFile Lib "kernel32" Alias "CopyFileA"
(ByVal lpExistingFileName As String, ByVal lpNewFileName
As String, ByVal bFailIfExists As Long) As Long

The DLL is KERNEL32.DLL, the function is CopyFile (the
arguments must be known).

If an ActiveX DLL (or EXE)

Set Myobj=CreateObject(name.class)

e.g.

Set objWrd=CreateObject("Word.Application")
Set objAPL=CreateObject("APLW.WSEngine")

-----Original Message-----
Hello all,
Is there a way to programatically add a reference to a

dll or .xla file from
an Excel workbook? (i.e. ToolsReferences from the VB

Editor) .

Thanks,
Andrew


.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Adding reference in code

Thanks for the prompt reply. I'm looking to programatically add a VB
Reference, not an Add-In. Is it possible? In the second example you
provided, you are demonstrating late-binding. I'm looking for a way to add
a reference to an .xla file so that the public functions in that .xla file
are available for use in the current workbook.

Thanks,
Andrew

"AA" wrote in message
...
To add an XLA file:

AddIns("ODBC Add-in").Installed = True

ODBC Add-in is added; setting to False removes it.

If a Win32 DLL, then something like:

Declare Function CopyFile Lib "kernel32" Alias "CopyFileA"
(ByVal lpExistingFileName As String, ByVal lpNewFileName
As String, ByVal bFailIfExists As Long) As Long

The DLL is KERNEL32.DLL, the function is CopyFile (the
arguments must be known).

If an ActiveX DLL (or EXE)

Set Myobj=CreateObject(name.class)

e.g.

Set objWrd=CreateObject("Word.Application")
Set objAPL=CreateObject("APLW.WSEngine")

-----Original Message-----
Hello all,
Is there a way to programatically add a reference to a

dll or .xla file from
an Excel workbook? (i.e. ToolsReferences from the VB

Editor) .

Thanks,
Andrew


.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Adding reference in code

Andrew,

Try something like the following:

ThisWorkbook.VBProject.References.AddFromFile _
Filename:=Application.AddIns("addin_name").FullNam e


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com

"Andrew O'Brien" <trinitywallstreet.org@aobrien wrote in message
...
Thanks for the prompt reply. I'm looking to programatically add a VB
Reference, not an Add-In. Is it possible? In the second example you
provided, you are demonstrating late-binding. I'm looking for a way to

add
a reference to an .xla file so that the public functions in that .xla file
are available for use in the current workbook.

Thanks,
Andrew

"AA" wrote in message
...
To add an XLA file:

AddIns("ODBC Add-in").Installed = True

ODBC Add-in is added; setting to False removes it.

If a Win32 DLL, then something like:

Declare Function CopyFile Lib "kernel32" Alias "CopyFileA"
(ByVal lpExistingFileName As String, ByVal lpNewFileName
As String, ByVal bFailIfExists As Long) As Long

The DLL is KERNEL32.DLL, the function is CopyFile (the
arguments must be known).

If an ActiveX DLL (or EXE)

Set Myobj=CreateObject(name.class)

e.g.

Set objWrd=CreateObject("Word.Application")
Set objAPL=CreateObject("APLW.WSEngine")

-----Original Message-----
Hello all,
Is there a way to programatically add a reference to a

dll or .xla file from
an Excel workbook? (i.e. ToolsReferences from the VB

Editor) .

Thanks,
Andrew


.





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Adding reference in code

Thank you so much, Chip. This is exactly what I was looking for.

"Chip Pearson" wrote in message
...
Andrew,

Try something like the following:

ThisWorkbook.VBProject.References.AddFromFile _
Filename:=Application.AddIns("addin_name").FullNam e


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com

"Andrew O'Brien" <trinitywallstreet.org@aobrien wrote in message
...
Thanks for the prompt reply. I'm looking to programatically add a VB
Reference, not an Add-In. Is it possible? In the second example you
provided, you are demonstrating late-binding. I'm looking for a way to

add
a reference to an .xla file so that the public functions in that .xla

file
are available for use in the current workbook.

Thanks,
Andrew

"AA" wrote in message
...
To add an XLA file:

AddIns("ODBC Add-in").Installed = True

ODBC Add-in is added; setting to False removes it.

If a Win32 DLL, then something like:

Declare Function CopyFile Lib "kernel32" Alias "CopyFileA"
(ByVal lpExistingFileName As String, ByVal lpNewFileName
As String, ByVal bFailIfExists As Long) As Long

The DLL is KERNEL32.DLL, the function is CopyFile (the
arguments must be known).

If an ActiveX DLL (or EXE)

Set Myobj=CreateObject(name.class)

e.g.

Set objWrd=CreateObject("Word.Application")
Set objAPL=CreateObject("APLW.WSEngine")

-----Original Message-----
Hello all,
Is there a way to programatically add a reference to a
dll or .xla file from
an Excel workbook? (i.e. ToolsReferences from the VB
Editor) .

Thanks,
Andrew


.









  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Adding reference in code

If you have added an addin, either with

AddIns("ODBC Add-in").Installed = True

or with Tools|AddIns etc,

the functions in that XLA become available. You can use
them in the worksheet

=fnname(arg1,,arg2)

or in macros

ActiveCell.FormulaR1C1 = "=fname(arg1,,arg2)"

IF you need the value in the macro, read it from the
activecell or other cell where you have written it.

-----Original Message-----
Thanks for the prompt reply. I'm looking to

programatically add a VB
Reference, not an Add-In. Is it possible? In the second

example you
provided, you are demonstrating late-binding. I'm

looking for a way to add
a reference to an .xla file so that the public functions

in that .xla file
are available for use in the current workbook.

Thanks,
Andrew

"AA" wrote in

message
...
To add an XLA file:

AddIns("ODBC Add-in").Installed = True

ODBC Add-in is added; setting to False removes it.

If a Win32 DLL, then something like:

Declare Function CopyFile Lib "kernel32"

Alias "CopyFileA"
(ByVal lpExistingFileName As String, ByVal lpNewFileName
As String, ByVal bFailIfExists As Long) As Long

The DLL is KERNEL32.DLL, the function is CopyFile (the
arguments must be known).

If an ActiveX DLL (or EXE)

Set Myobj=CreateObject(name.class)

e.g.

Set objWrd=CreateObject("Word.Application")
Set objAPL=CreateObject("APLW.WSEngine")

-----Original Message-----
Hello all,
Is there a way to programatically add a reference to a

dll or .xla file from
an Excel workbook? (i.e. ToolsReferences from the VB

Editor) .

Thanks,
Andrew


.



.

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Adding reference in code

You're right. I'm sorry, I don't think I was clear about what I was looking
for. I needed to make the external formulas available on the document
level...not the Excel application level. For example, if I create workbook
wb1.xls, I want to have a reference saved with the workbook to lib1.xla so
that I don't have to worry about whether or not another user has the add-in
installed. Thanks again.

"AA" wrote in message
...
If you have added an addin, either with

AddIns("ODBC Add-in").Installed = True

or with Tools|AddIns etc,

the functions in that XLA become available. You can use
them in the worksheet

=fnname(arg1,,arg2)

or in macros

ActiveCell.FormulaR1C1 = "=fname(arg1,,arg2)"

IF you need the value in the macro, read it from the
activecell or other cell where you have written it.

-----Original Message-----
Thanks for the prompt reply. I'm looking to

programatically add a VB
Reference, not an Add-In. Is it possible? In the second

example you
provided, you are demonstrating late-binding. I'm

looking for a way to add
a reference to an .xla file so that the public functions

in that .xla file
are available for use in the current workbook.

Thanks,
Andrew

"AA" wrote in

message
...
To add an XLA file:

AddIns("ODBC Add-in").Installed = True

ODBC Add-in is added; setting to False removes it.

If a Win32 DLL, then something like:

Declare Function CopyFile Lib "kernel32"

Alias "CopyFileA"
(ByVal lpExistingFileName As String, ByVal lpNewFileName
As String, ByVal bFailIfExists As Long) As Long

The DLL is KERNEL32.DLL, the function is CopyFile (the
arguments must be known).

If an ActiveX DLL (or EXE)

Set Myobj=CreateObject(name.class)

e.g.

Set objWrd=CreateObject("Word.Application")
Set objAPL=CreateObject("APLW.WSEngine")

-----Original Message-----
Hello all,
Is there a way to programatically add a reference to a
dll or .xla file from
an Excel workbook? (i.e. ToolsReferences from the VB
Editor) .

Thanks,
Andrew


.



.



  #8   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.office.developer.automation,microsoft.public.office.developer.vba
external usenet poster
 
Posts: 7,247
Default Adding reference in code

Andrew,

Try something like

ThisWorkbook.VBProject.References.AddFromFile _
Filename:="C:\filename.xla"


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Andrew O'Brien" <trinitywallstreet.org@aobrien wrote in message
...
Hello all,
Is there a way to programatically add a reference to a dll or .xla file

from
an Excel workbook? (i.e. ToolsReferences from the VB Editor) .

Thanks,
Andrew




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
adding an autoshape to vba code NG Excel Discussion (Misc queries) 0 October 19th 09 07:44 PM
Adding code to a macro Excel Helps Excel Worksheet Functions 2 January 23rd 08 06:15 PM
adding a phone area code that is not there Kelly Excel Discussion (Misc queries) 4 December 13th 06 12:15 AM
adding and subtracting using vb code ASU Excel Discussion (Misc queries) 2 October 7th 06 09:48 AM
bar code help, adding asterix to reference R D S Excel Discussion (Misc queries) 1 January 17th 05 06:05 PM


All times are GMT +1. The time now is 04:54 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"