Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 201
Default VBA code to set a reference

Sort of fixed it.

The error (Can't enter break mode at this time.) only occurs if you are
stepping through the code, if you just let it run it appears to be fine. I am
still playing so will see.

Anyway thanks everyone for your input.

--
Trefor


"Tom Ogilvy" wrote:

Yep, that's what I have been doing


OK, I guess you threw me off when you posted:

This works, . . .
ThisWorkbook.VBProject.References.AddFromFile "C:\DataCollectMaster.xla"


I have no idea what would cause that message. I don't believe it is
specifically associated with adding a reference

From what I could find, it was suggested that you

Turn off the "Require Variable Declaration" in tools=Options in the editor
Tab in the VBE.

You can still manually put Option Explicit at the top of each module.

Let me know if that works.

--
Regards,
Tom Ogilvy

"Trefor" wrote in message
...
Yep, that's what I have been doing and it does work, but it also gives me

a
message as discribed earlier.

--
Trefor


"Tom Ogilvy" wrote:

Yep, the Project name is: "DataCollectMaster"
The file name is "Customer Data Collect Master.xla"


based on that information you should be using the filename:


ThisWorkbook.VBProject.References _
.AddFromFile "C:\Customer Data Collect Master.xla"

--
Regards,
Tom Ogilvy




"Trefor" wrote in message
...
Tom,

Yep, the Project name is: "DataCollectMaster"
The file name is "Customer Data Collect Master.xla"

--
Trefor


"Tom Ogilvy" wrote:

Does your xla have a unique project name or is it still the default
vbaProject? If it is, try changing it.

--
Regards,
Tom Ogilvy


"Trefor" wrote in message
...
Chijanzen,

This works, but gives me the same error as before (Can't enter

break
mode
at
this time.)

ThisWorkbook.VBProject.References.AddFromFile
"C:\DataCollectMaster.xla"

The remove reference works fine thankyou.

--
Trefor


"chijanzen" wrote:

Trefor:

' adding of a DataCollectMaster Addin refernce

ThisWorkbook.VBProject.References.AddFromFile
"C:\DataCollectMaster.xla"



' Remove References
With ThisWorkbook.VBProject
For i = 1 To .References.Count
If .References(i).Name = "DataCollectMaster" Then
.References.Remove .References(i)
End If
Next i
End With

--
http://www.vba.com.tw/plog/


"Trefor" wrote:

Chijanzen,

Thankyou for your reply.

The reference is for my add-in so:

With ThisWorkbook.VBProject
Set Ref = .References("DataCollectMaster") ' Ref.Name
If Not Ref Is Nothing Then
.References.Remove Ref <-- Can't enter break mode at

this
time.
End If
End With

I get the above error, otherwise the reference did get

removed.

can you show me how to code adding this add-in by its name?

--
Trefor


"chijanzen" wrote:

Trefor:

If you want to adding of a refernce "Microsoft Office

Outlook
11.0
Object
Library"

With ThisWorkbook.VBProject
On Error Resume Next
Set Ref = .References("Outlook")
If Err = 0 Then
'Remove of a Outlook refernce
.References.Remove Ref
Else
'adding of a Outlook refernce
ThisWorkbook.VBProject.References.AddFromGuid _

"{00062FFF-0000-0000-C000-000000000046}", 1,
0
End If
End With

--

http://www.vba.com.tw/plog/


"Trefor" wrote:

Is it possible to code the adding of a refernce (VBE -

Tools
Refernce)? Is
it also possible to remove this reference?

--
Trefor









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 make a button VBA code reference other VBA code subroutines??? gunman[_9_] Excel Programming 4 September 27th 05 01:01 AM
Hard Code DLL Reference in VBA alex Excel Programming 0 June 10th 04 01:20 PM
Code Reference Problem Todd Huttenstine Excel Programming 0 April 28th 04 09:32 PM
remove reference via code Brian Excel Programming 1 April 22nd 04 06:10 PM
Reference a Column in Code Wally Steadman[_3_] Excel Programming 1 November 17th 03 11:26 AM


All times are GMT +1. The time now is 04:07 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"