Turn on reference within a macro

D

dawsonsc

Hello,

I was wondering if it was possible to run a macro that would turn on a
reference? Specifically, the Adobe Distiller reference (VBa editor ->
Tools -> References). I would like for my spreadsheet template to
have it turned off by default, but if a user wants to run a macro that
calls the distiller then the reference would turn on.


Is this possible?

Thanks in advance for any responses.
 
J

JW

Hello,

I was wondering if it was possible to run a macro that would turn on a
reference?  Specifically, the Adobe Distiller reference (VBa editor ->
Tools -> References).  I would like for my spreadsheet template to
have it turned off by default, but if a user wants to run a macro that
calls the distiller then the reference would turn on.

Is this possible?

Thanks in advance for any responses.

Give something like this a shot, changing the Item to whatever your
reference is.

Sub Remove_Reference()
Dim x As Object
Set x = Application.VBE.ActiveVBProject _
.References.Item("R8ole32.tlb")
Application.VBE.ActiveVBProject.References.Remove x
End Sub
 
D

dawsonsc

Give something like this a shot, changing the Item to whatever your
reference is.

Sub Remove_Reference()
Dim x As Object
Set x = Application.VBE.ActiveVBProject _
.References.Item("R8ole32.tlb")
Application.VBE.ActiveVBProject.References.Remove x
End Sub

Thanks JW, that does seem to work to remove the reference. What would
I need to turn a reference on?
 
D

dawsonsc

Thanks JW, that does seem to work to remove the reference. What would
I need to turn a reference on?

Maybe something like this:

Sub Add_reference()
Application.VBE.ActiveVBProject.References.AddFromFile ("C:
\Program Files\Adobe\Acrobat 7.0\Distillr\acrodist.exe")
End Sub

Seems to work. Kind of simple though, not sure if I am over looking
anything. Thanks for pointing me in the direction of
Application.VBE.ActiveVBProject.References . Much appreciated.
 
J

JW

Maybe something like this:

Sub Add_reference()
    Application.VBE.ActiveVBProject.References.AddFromFile ("C:
\Program Files\Adobe\Acrobat 7.0\Distillr\acrodist.exe")
End Sub

Seems to work.  Kind of simple though, not sure if I am over looking
anything.  Thanks for pointing me in the direction of
Application.VBE.ActiveVBProject.References .  Much appreciated.- Hide quoted text -

- Show quoted text -

Yup, that would be the way I would handle it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top