Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Removing references

Hi I wonder if anyone can help with this. I am trying to use the
following code to remove a reference to a project in VBA so that I can
then close that workbook from with the active workbook.

The code seems to obey all the structures as set out in VBA help but
it, and as many variants as I can try, don't work.

Does anyone know how to do this

Many Thanks in anticipation

Steve

Code:-


Sub remref001()
Dim str001 As Reference
Set str001 = Application.VBE.ActiveVBProject.References(7)
str001.Remove
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default Removing references

UnTested...
try...
activeworkbook.VBProject.References.Remove(str001)


-----Original Message-----
Hi I wonder if anyone can help with this. I am trying to

use the
following code to remove a reference to a project in VBA

so that I can
then close that workbook from with the active workbook.

The code seems to obey all the structures as set out in

VBA help but
it, and as many variants as I can try, don't work.

Does anyone know how to do this

Many Thanks in anticipation

Steve

Code:-


Sub remref001()
Dim str001 As Reference
Set str001 =

Application.VBE.ActiveVBProject.References(7)
str001.Remove
End Sub
.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Removing references


Sorry that was one of the variants I tried (tried it again though just
in case)

Basically the syntax seems OK but VBA comes back with "object doesn't
support this method"

Anyone any more ideas

Steve


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Removing references

using the () is a syntax violation - it evaluates the object and returns the
default value which isn't applicable as an argument. so removed the ()

activeworkbook.VBProject.References.Remove str001

so if you have a reference to the VBA extensibility Library

Sub AABB()
Dim str001 As Reference
Set str001 = ActiveWorkbook.VBProject.References(7)
ActiveWorkbook.VBProject.References.Remove str001
End Sub

if not

Sub AABB()
Dim str001 As Object
Set str001 = ActiveWorkbook.VBProject.References(7)
ActiveWorkbook.VBProject.References.Remove str001
End Sub

--
Regards,
Tom Ogilvy

"Steve" wrote in message
...

Sorry that was one of the variants I tried (tried it again though just
in case)

Basically the syntax seems OK but VBA comes back with "object doesn't
support this method"

Anyone any more ideas

Steve


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Removing references

Tom

Brilliant as usual ! Many Thanks.

Steve

"Tom Ogilvy" wrote in message
...
using the () is a syntax violation - it evaluates the object and returns

the
default value which isn't applicable as an argument. so removed the ()

activeworkbook.VBProject.References.Remove str001

so if you have a reference to the VBA extensibility Library

Sub AABB()
Dim str001 As Reference
Set str001 = ActiveWorkbook.VBProject.References(7)
ActiveWorkbook.VBProject.References.Remove str001
End Sub

if not

Sub AABB()
Dim str001 As Object
Set str001 = ActiveWorkbook.VBProject.References(7)
ActiveWorkbook.VBProject.References.Remove str001
End Sub

--
Regards,
Tom Ogilvy

"Steve" wrote in message
...

Sorry that was one of the variants I tried (tried it again though just
in case)

Basically the syntax seems OK but VBA comes back with "object doesn't
support this method"

Anyone any more ideas

Steve


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!





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
How to convert all 3d references to normal references in a workboo Dima Excel Discussion (Misc queries) 6 August 8th 08 12:38 PM
How to convert all 3d references to normal references in a workboo Dima Excel Worksheet Functions 6 August 8th 08 12:38 PM
Help with converting a block of cells with Absolute and mixed references to relative references Vulcan Excel Worksheet Functions 3 December 13th 07 11:43 PM
How to rename references from range names to cell references Abbas Excel Discussion (Misc queries) 1 May 24th 06 06:18 PM
Removing circular references without the use of macros? mattflow Excel Discussion (Misc queries) 3 July 20th 05 04:29 PM


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

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

About Us

"It's about Microsoft Excel"