PC Review


Reply
Thread Tools Rate Thread

Change Location of VBE References with VBA

 
 
=?Utf-8?B?dnF0aG9tZg==?=
Guest
Posts: n/a
 
      24th Jul 2007
Hi all I was wondering if Reference location be changed using vba code I have
tried using Application.VBE.ActiveVBProject.References.AddFromFile but I need
to remove the reference before adding a new one when I try to remove the it I
get an error has one done this before if so can you please help?.
TIA
Charles
 
Reply With Quote
 
 
 
 
Peter T
Guest
Posts: n/a
 
      24th Jul 2007
Hi Charles,

Without seeing your code its not possible to know if it fails because the
code is wrong or fails for some other reason, eg the reference doesn't
exist. Try something like this -

Dim rf As Reference

'With ThisWorkbook.VBProject.References
With Application.VBE.ActiveVBProject.References
On Error Resume Next
Set rf = .Item("ref name to be removed")
If Not rf Is Nothing Then
.Remove rf
Else
' ref doesn't exist
End If
End With

Regards,
Peter T

"vqthomf" <(E-Mail Removed)> wrote in message
news:57D9ED2C-D729-40B0-8113-(E-Mail Removed)...
> Hi all I was wondering if Reference location be changed using vba code I

have
> tried using Application.VBE.ActiveVBProject.References.AddFromFile but I

need
> to remove the reference before adding a new one when I try to remove the

it I
> get an error has one done this before if so can you please help?.
> TIA
> Charles



 
Reply With Quote
 
=?Utf-8?B?dnF0aG9tZg==?=
Guest
Posts: n/a
 
      24th Jul 2007
I think my Idea of a reference is wrong?
I am trying to change the location of this file Y:\Quality\GALC system\HTR
support\Turkey\Data Files\msadox.dll to another location can this be done as
nothing I have tried works.
TIA
Charles

"Peter T" wrote:

> Hi Charles,
>
> Without seeing your code its not possible to know if it fails because the
> code is wrong or fails for some other reason, eg the reference doesn't
> exist. Try something like this -
>
> Dim rf As Reference
>
> 'With ThisWorkbook.VBProject.References
> With Application.VBE.ActiveVBProject.References
> On Error Resume Next
> Set rf = .Item("ref name to be removed")
> If Not rf Is Nothing Then
> .Remove rf
> Else
> ' ref doesn't exist
> End If
> End With
>
> Regards,
> Peter T
>
> "vqthomf" <(E-Mail Removed)> wrote in message
> news:57D9ED2C-D729-40B0-8113-(E-Mail Removed)...
> > Hi all I was wondering if Reference location be changed using vba code I

> have
> > tried using Application.VBE.ActiveVBProject.References.AddFromFile but I

> need
> > to remove the reference before adding a new one when I try to remove the

> it I
> > get an error has one done this before if so can you please help?.
> > TIA
> > Charles

>
>
>

 
Reply With Quote
 
Peter T
Guest
Posts: n/a
 
      24th Jul 2007
> I think my Idea of a reference is wrong?

Is that a question?

Difficult to understand what you are doing and why you want to change file
location of the dll. However if that's what you are doing, and the dll is an
ActiveX, you will need to re-register the dll. Having done that, providing
the dll is the same version or later as that to which a reference was set in
your project, you shouldn't need to remove and re-add the reference to your
project.

Regards,
Peter T

"vqthomf" <(E-Mail Removed)> wrote in message
news:3F61C059-33E6-450B-BAEA-(E-Mail Removed)...
> I think my Idea of a reference is wrong?
> I am trying to change the location of this file Y:\Quality\GALC system\HTR
> support\Turkey\Data Files\msadox.dll to another location can this be done

as
> nothing I have tried works.
> TIA
> Charles
>
> "Peter T" wrote:
>
> > Hi Charles,
> >
> > Without seeing your code its not possible to know if it fails because

the
> > code is wrong or fails for some other reason, eg the reference doesn't
> > exist. Try something like this -
> >
> > Dim rf As Reference
> >
> > 'With ThisWorkbook.VBProject.References
> > With Application.VBE.ActiveVBProject.References
> > On Error Resume Next
> > Set rf = .Item("ref name to be removed")
> > If Not rf Is Nothing Then
> > .Remove rf
> > Else
> > ' ref doesn't exist
> > End If
> > End With
> >
> > Regards,
> > Peter T
> >
> > "vqthomf" <(E-Mail Removed)> wrote in message
> > news:57D9ED2C-D729-40B0-8113-(E-Mail Removed)...
> > > Hi all I was wondering if Reference location be changed using vba code

I
> > have
> > > tried using Application.VBE.ActiveVBProject.References.AddFromFile but

I
> > need
> > > to remove the reference before adding a new one when I try to remove

the
> > it I
> > > get an error has one done this before if so can you please help?.
> > > TIA
> > > Charles

> >
> >
> >



 
Reply With Quote
 
=?Utf-8?B?dnF0aG9tZg==?=
Guest
Posts: n/a
 
      24th Jul 2007
we are supporting a sister company in Turkey and the report programmes that
we build and test here work fine but when we send it you them it wont work
due to references!, I wanted to have the programme know where it is and
change the location.
TIA
Charles

"Peter T" wrote:

> > I think my Idea of a reference is wrong?

>
> Is that a question?
>
> Difficult to understand what you are doing and why you want to change file
> location of the dll. However if that's what you are doing, and the dll is an
> ActiveX, you will need to re-register the dll. Having done that, providing
> the dll is the same version or later as that to which a reference was set in
> your project, you shouldn't need to remove and re-add the reference to your
> project.
>
> Regards,
> Peter T
>
> "vqthomf" <(E-Mail Removed)> wrote in message
> news:3F61C059-33E6-450B-BAEA-(E-Mail Removed)...
> > I think my Idea of a reference is wrong?
> > I am trying to change the location of this file Y:\Quality\GALC system\HTR
> > support\Turkey\Data Files\msadox.dll to another location can this be done

> as
> > nothing I have tried works.
> > TIA
> > Charles
> >
> > "Peter T" wrote:
> >
> > > Hi Charles,
> > >
> > > Without seeing your code its not possible to know if it fails because

> the
> > > code is wrong or fails for some other reason, eg the reference doesn't
> > > exist. Try something like this -
> > >
> > > Dim rf As Reference
> > >
> > > 'With ThisWorkbook.VBProject.References
> > > With Application.VBE.ActiveVBProject.References
> > > On Error Resume Next
> > > Set rf = .Item("ref name to be removed")
> > > If Not rf Is Nothing Then
> > > .Remove rf
> > > Else
> > > ' ref doesn't exist
> > > End If
> > > End With
> > >
> > > Regards,
> > > Peter T
> > >
> > > "vqthomf" <(E-Mail Removed)> wrote in message
> > > news:57D9ED2C-D729-40B0-8113-(E-Mail Removed)...
> > > > Hi all I was wondering if Reference location be changed using vba code

> I
> > > have
> > > > tried using Application.VBE.ActiveVBProject.References.AddFromFile but

> I
> > > need
> > > > to remove the reference before adding a new one when I try to remove

> the
> > > it I
> > > > get an error has one done this before if so can you please help?.
> > > > TIA
> > > > Charles
> > >
> > >
> > >

>
>
>

 
Reply With Quote
 
Peter T
Guest
Posts: n/a
 
      24th Jul 2007
> I wanted to have the programme know where it is and
> change the location.


I don't think the location of the dll is not the issue, is it actually
registered on the target machine.

If it is registered it might be an older version (along the lines I
mentioned previously), have you checked. If so removing (as per example
posted previously) and re-adding the reference might work.

Regards,
Peter T

"vqthomf" <(E-Mail Removed)> wrote in message
news:8BDF541D-1946-4261-B429-(E-Mail Removed)...
> we are supporting a sister company in Turkey and the report programmes

that
> we build and test here work fine but when we send it you them it wont work
> due to references!, I wanted to have the programme know where it is and
> change the location.
> TIA
> Charles
>
> "Peter T" wrote:
>
> > > I think my Idea of a reference is wrong?

> >
> > Is that a question?
> >
> > Difficult to understand what you are doing and why you want to change

file
> > location of the dll. However if that's what you are doing, and the dll

is an
> > ActiveX, you will need to re-register the dll. Having done that,

providing
> > the dll is the same version or later as that to which a reference was

set in
> > your project, you shouldn't need to remove and re-add the reference to

your
> > project.
> >
> > Regards,
> > Peter T
> >
> > "vqthomf" <(E-Mail Removed)> wrote in message
> > news:3F61C059-33E6-450B-BAEA-(E-Mail Removed)...
> > > I think my Idea of a reference is wrong?
> > > I am trying to change the location of this file Y:\Quality\GALC

system\HTR
> > > support\Turkey\Data Files\msadox.dll to another location can this be

done
> > as
> > > nothing I have tried works.
> > > TIA
> > > Charles
> > >
> > > "Peter T" wrote:
> > >
> > > > Hi Charles,
> > > >
> > > > Without seeing your code its not possible to know if it fails

because
> > the
> > > > code is wrong or fails for some other reason, eg the reference

doesn't
> > > > exist. Try something like this -
> > > >
> > > > Dim rf As Reference
> > > >
> > > > 'With ThisWorkbook.VBProject.References
> > > > With Application.VBE.ActiveVBProject.References
> > > > On Error Resume Next
> > > > Set rf = .Item("ref name to be removed")
> > > > If Not rf Is Nothing Then
> > > > .Remove rf
> > > > Else
> > > > ' ref doesn't exist
> > > > End If
> > > > End With
> > > >
> > > > Regards,
> > > > Peter T
> > > >
> > > > "vqthomf" <(E-Mail Removed)> wrote in message
> > > > news:57D9ED2C-D729-40B0-8113-(E-Mail Removed)...
> > > > > Hi all I was wondering if Reference location be changed using vba

code
> > I
> > > > have
> > > > > tried using Application.VBE.ActiveVBProject.References.AddFromFile

but
> > I
> > > > need
> > > > > to remove the reference before adding a new one when I try to

remove
> > the
> > > > it I
> > > > > get an error has one done this before if so can you please help?.
> > > > > TIA
> > > > > Charles
> > > >
> > > >
> > > >

> >
> >
> >



 
Reply With Quote
 
=?Utf-8?B?dnF0aG9tZg==?=
Guest
Posts: n/a
 
      24th Jul 2007
I tried the code you gaive me but I still get an error, their location is in
Trukish and that why it can't fine the dll's and when there is a problem or
they want an upgrade they send it back and we have to manaualy change it.

"Peter T" wrote:

> > I wanted to have the programme know where it is and
> > change the location.

>
> I don't think the location of the dll is not the issue, is it actually
> registered on the target machine.
>
> If it is registered it might be an older version (along the lines I
> mentioned previously), have you checked. If so removing (as per example
> posted previously) and re-adding the reference might work.
>
> Regards,
> Peter T
>
> "vqthomf" <(E-Mail Removed)> wrote in message
> news:8BDF541D-1946-4261-B429-(E-Mail Removed)...
> > we are supporting a sister company in Turkey and the report programmes

> that
> > we build and test here work fine but when we send it you them it wont work
> > due to references!, I wanted to have the programme know where it is and
> > change the location.
> > TIA
> > Charles
> >
> > "Peter T" wrote:
> >
> > > > I think my Idea of a reference is wrong?
> > >
> > > Is that a question?
> > >
> > > Difficult to understand what you are doing and why you want to change

> file
> > > location of the dll. However if that's what you are doing, and the dll

> is an
> > > ActiveX, you will need to re-register the dll. Having done that,

> providing
> > > the dll is the same version or later as that to which a reference was

> set in
> > > your project, you shouldn't need to remove and re-add the reference to

> your
> > > project.
> > >
> > > Regards,
> > > Peter T
> > >
> > > "vqthomf" <(E-Mail Removed)> wrote in message
> > > news:3F61C059-33E6-450B-BAEA-(E-Mail Removed)...
> > > > I think my Idea of a reference is wrong?
> > > > I am trying to change the location of this file Y:\Quality\GALC

> system\HTR
> > > > support\Turkey\Data Files\msadox.dll to another location can this be

> done
> > > as
> > > > nothing I have tried works.
> > > > TIA
> > > > Charles
> > > >
> > > > "Peter T" wrote:
> > > >
> > > > > Hi Charles,
> > > > >
> > > > > Without seeing your code its not possible to know if it fails

> because
> > > the
> > > > > code is wrong or fails for some other reason, eg the reference

> doesn't
> > > > > exist. Try something like this -
> > > > >
> > > > > Dim rf As Reference
> > > > >
> > > > > 'With ThisWorkbook.VBProject.References
> > > > > With Application.VBE.ActiveVBProject.References
> > > > > On Error Resume Next
> > > > > Set rf = .Item("ref name to be removed")
> > > > > If Not rf Is Nothing Then
> > > > > .Remove rf
> > > > > Else
> > > > > ' ref doesn't exist
> > > > > End If
> > > > > End With
> > > > >
> > > > > Regards,
> > > > > Peter T
> > > > >
> > > > > "vqthomf" <(E-Mail Removed)> wrote in message
> > > > > news:57D9ED2C-D729-40B0-8113-(E-Mail Removed)...
> > > > > > Hi all I was wondering if Reference location be changed using vba

> code
> > > I
> > > > > have
> > > > > > tried using Application.VBE.ActiveVBProject.References.AddFromFile

> but
> > > I
> > > > > need
> > > > > > to remove the reference before adding a new one when I try to

> remove
> > > the
> > > > > it I
> > > > > > get an error has one done this before if so can you please help?.
> > > > > > TIA
> > > > > > Charles
> > > > >
> > > > >
> > > > >
> > >
> > >
> > >

>
>
>

 
Reply With Quote
 
Peter T
Guest
Posts: n/a
 
      24th Jul 2007
Did you digest this part of my previous post -

> > I don't think the location of the dll is not the issue, is it actually
> > registered on the target machine.


What's the answer to this question.

Regards,
Peter T

"vqthomf" <(E-Mail Removed)> wrote in message
news:318AD18D-67A8-44B3-BE72-(E-Mail Removed)...
> I tried the code you gaive me but I still get an error, their location is

in
> Trukish and that why it can't fine the dll's and when there is a problem

or
> they want an upgrade they send it back and we have to manaualy change it.
>
> "Peter T" wrote:
>
> > > I wanted to have the programme know where it is and
> > > change the location.

> >
> > I don't think the location of the dll is not the issue, is it actually
> > registered on the target machine.
> >
> > If it is registered it might be an older version (along the lines I
> > mentioned previously), have you checked. If so removing (as per example
> > posted previously) and re-adding the reference might work.
> >
> > Regards,
> > Peter T
> >
> > "vqthomf" <(E-Mail Removed)> wrote in message
> > news:8BDF541D-1946-4261-B429-(E-Mail Removed)...
> > > we are supporting a sister company in Turkey and the report programmes

> > that
> > > we build and test here work fine but when we send it you them it wont

work
> > > due to references!, I wanted to have the programme know where it is

and
> > > change the location.
> > > TIA
> > > Charles
> > >
> > > "Peter T" wrote:
> > >
> > > > > I think my Idea of a reference is wrong?
> > > >
> > > > Is that a question?
> > > >
> > > > Difficult to understand what you are doing and why you want to

change
> > file
> > > > location of the dll. However if that's what you are doing, and the

dll
> > is an
> > > > ActiveX, you will need to re-register the dll. Having done that,

> > providing
> > > > the dll is the same version or later as that to which a reference

was
> > set in
> > > > your project, you shouldn't need to remove and re-add the reference

to
> > your
> > > > project.
> > > >
> > > > Regards,
> > > > Peter T
> > > >
> > > > "vqthomf" <(E-Mail Removed)> wrote in message
> > > > news:3F61C059-33E6-450B-BAEA-(E-Mail Removed)...
> > > > > I think my Idea of a reference is wrong?
> > > > > I am trying to change the location of this file Y:\Quality\GALC

> > system\HTR
> > > > > support\Turkey\Data Files\msadox.dll to another location can this

be
> > done
> > > > as
> > > > > nothing I have tried works.
> > > > > TIA
> > > > > Charles
> > > > >
> > > > > "Peter T" wrote:
> > > > >
> > > > > > Hi Charles,
> > > > > >
> > > > > > Without seeing your code its not possible to know if it fails

> > because
> > > > the
> > > > > > code is wrong or fails for some other reason, eg the reference

> > doesn't
> > > > > > exist. Try something like this -
> > > > > >
> > > > > > Dim rf As Reference
> > > > > >
> > > > > > 'With ThisWorkbook.VBProject.References
> > > > > > With Application.VBE.ActiveVBProject.References
> > > > > > On Error Resume Next
> > > > > > Set rf = .Item("ref name to be removed")
> > > > > > If Not rf Is Nothing Then
> > > > > > .Remove rf
> > > > > > Else
> > > > > > ' ref doesn't exist
> > > > > > End If
> > > > > > End With
> > > > > >
> > > > > > Regards,
> > > > > > Peter T
> > > > > >
> > > > > > "vqthomf" <(E-Mail Removed)> wrote in message
> > > > > > news:57D9ED2C-D729-40B0-8113-(E-Mail Removed)...
> > > > > > > Hi all I was wondering if Reference location be changed using

vba
> > code
> > > > I
> > > > > > have
> > > > > > > tried using

Application.VBE.ActiveVBProject.References.AddFromFile
> > but
> > > > I
> > > > > > need
> > > > > > > to remove the reference before adding a new one when I try to

> > remove
> > > > the
> > > > > > it I
> > > > > > > get an error has one done this before if so can you please

help?.
> > > > > > > TIA
> > > > > > > Charles
> > > > > >
> > > > > >
> > > > > >
> > > >
> > > >
> > > >

> >
> >
> >



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Change location of the storage location for mail and address book JorgenNM Microsoft Outlook Installation 4 1st Oct 2008 06:25 AM
Need to change physical location of Externally Linked Tables - Possible to fake out network server location? Tagman Microsoft Access 2 6th Apr 2008 08:07 PM
Location for References in projects =?Utf-8?B?Um9nZXIgVHJhbmNoZXo=?= Microsoft Dot NET Framework 7 12th Jun 2007 07:59 AM
Registry Location for References in VBe Mike McNeill Microsoft Excel Programming 4 22nd Dec 2006 11:40 AM
Setting References with VBA - Custom Location of DLL microb0x Microsoft Access 2 8th Sep 2006 03:40 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:28 AM.