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

I want to create a set of VB statements that will set the object references
required for my VBA code, such as, for the following,

Visual basic for applications
Microsoft Excel 11.0 Object Library
OLE Automation
Microsoft Office 11.0 Object Library
Microsoft Project 11.0 Object Library
Microsoft ActiveX Data Objects 2.8 Library
Microsoft ActiveX Data Objects Recordset 2.7 Library

Have them compiled to .exe and then call it at the start of my VBA code.

This is to create the references without the user having to do it themselves.

I suppose it would be necessary to check whether the refernces are already
set, if so then skip this step.

Can someone please show me a few lines of, how to do this.

Thanks,
--
Sajit

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default VB code to set VBA References

This is part of the answer:
http://www.cpearson.com/excel/vbe.htm

Presumably you have VB6 or similar to create your .exe file
However, you could use late-binding and avoid the reference issue.

NickHK

"Sajit" wrote in message
...
I want to create a set of VB statements that will set the object

references
required for my VBA code, such as, for the following,

Visual basic for applications
Microsoft Excel 11.0 Object Library
OLE Automation
Microsoft Office 11.0 Object Library
Microsoft Project 11.0 Object Library
Microsoft ActiveX Data Objects 2.8 Library
Microsoft ActiveX Data Objects Recordset 2.7 Library

Have them compiled to .exe and then call it at the start of my VBA code.

This is to create the references without the user having to do it

themselves.

I suppose it would be necessary to check whether the refernces are already
set, if so then skip this step.

Can someone please show me a few lines of, how to do this.

Thanks,
--
Sajit



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 42
Default VB code to set VBA References

On Jul 22, 10:44 pm, Sajit wrote:
I want to create a set of VB statements that will set the object references
required for my VBA code, such as, for the following,

Visual basic for applications
Microsoft Excel 11.0 Object Library
OLE Automation
Microsoft Office 11.0 Object Library
Microsoft Project 11.0 Object Library
Microsoft ActiveX Data Objects 2.8 Library
Microsoft ActiveX Data Objects Recordset 2.7 Library

Have them compiled to .exe and then call it at the start of my VBA code.

This is to create the references without the user having to do it themselves.

I suppose it would be necessary to check whether the refernces are already
set, if so then skip this step.

You could use the workbook_open event.

Private Sub Workbook_Open()
ActiveWorkbook.VBProject.References.AddFromGuid "{GUID of
References}", 1, 0

End Sub

You can find the right GUIDs by searching the registry if you don't
know them.

Peter Richardson

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default VB code to set VBA References

I did not know what the GUID meant so I had to look up the help. I see from
the help,

Every type library has an associated GUID which is stored in the Registry.
When you set a reference to a type library, Microsoft Access uses the type
library's GUID to identify the type library.

I am wondering whether the GUID for a certain reference, will it be the
same, on 2 different PCs. I am asking this because, since I am trying to make
a common method for all the PCs connected on the server.
--
Sajit
Abu Dhabi


" wrote:

On Jul 22, 10:44 pm, Sajit wrote:
I want to create a set of VB statements that will set the object references
required for my VBA code, such as, for the following,

Visual basic for applications
Microsoft Excel 11.0 Object Library
OLE Automation
Microsoft Office 11.0 Object Library
Microsoft Project 11.0 Object Library
Microsoft ActiveX Data Objects 2.8 Library
Microsoft ActiveX Data Objects Recordset 2.7 Library

Have them compiled to .exe and then call it at the start of my VBA code.

This is to create the references without the user having to do it themselves.

I suppose it would be necessary to check whether the refernces are already
set, if so then skip this step.

You could use the workbook_open event.

Private Sub Workbook_Open()
ActiveWorkbook.VBProject.References.AddFromGuid "{GUID of
References}", 1, 0

End Sub

You can find the right GUIDs by searching the registry if you don't
know them.

Peter Richardson


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default VB code to set VBA References

Thanks,

There is a load of stuff to understand including some other thing related to
propagating VBA code to multiple Excel files.
--
Sajit
Abu Dhabi


"NickHK" wrote:

This is part of the answer:
http://www.cpearson.com/excel/vbe.htm

Presumably you have VB6 or similar to create your .exe file
However, you could use late-binding and avoid the reference issue.

NickHK

"Sajit" wrote in message
...
I want to create a set of VB statements that will set the object

references
required for my VBA code, such as, for the following,

Visual basic for applications
Microsoft Excel 11.0 Object Library
OLE Automation
Microsoft Office 11.0 Object Library
Microsoft Project 11.0 Object Library
Microsoft ActiveX Data Objects 2.8 Library
Microsoft ActiveX Data Objects Recordset 2.7 Library

Have them compiled to .exe and then call it at the start of my VBA code.

This is to create the references without the user having to do it

themselves.

I suppose it would be necessary to check whether the refernces are already
set, if so then skip this step.

Can someone please show me a few lines of, how to do this.

Thanks,
--
Sajit






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 119
Default VB code to set VBA References

As far as I know they are supposed to be the same on every machine for a
given library.

Peter Richardson

"Sajit" wrote:

I did not know what the GUID meant so I had to look up the help. I see from
the help,

Every type library has an associated GUID which is stored in the Registry.
When you set a reference to a type library, Microsoft Access uses the type
library's GUID to identify the type library.

I am wondering whether the GUID for a certain reference, will it be the
same, on 2 different PCs. I am asking this because, since I am trying to make
a common method for all the PCs connected on the server.
--
Sajit
Abu Dhabi


" wrote:

On Jul 22, 10:44 pm, Sajit wrote:
I want to create a set of VB statements that will set the object references
required for my VBA code, such as, for the following,

Visual basic for applications
Microsoft Excel 11.0 Object Library
OLE Automation
Microsoft Office 11.0 Object Library
Microsoft Project 11.0 Object Library
Microsoft ActiveX Data Objects 2.8 Library
Microsoft ActiveX Data Objects Recordset 2.7 Library

Have them compiled to .exe and then call it at the start of my VBA code.

This is to create the references without the user having to do it themselves.

I suppose it would be necessary to check whether the refernces are already
set, if so then skip this step.

You could use the workbook_open event.

Private Sub Workbook_Open()
ActiveWorkbook.VBProject.References.AddFromGuid "{GUID of
References}", 1, 0

End Sub

You can find the right GUIDs by searching the registry if you don't
know them.

Peter Richardson


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default VB code to set VBA References

I have gone through the material in the link.

There is a method to remove a module and then add a module. I need to
replace the code that is there is in the subs in between as well.

How does that happen?

--
Sajit
Abu Dhabi


"NickHK" wrote:

This is part of the answer:
http://www.cpearson.com/excel/vbe.htm

Presumably you have VB6 or similar to create your .exe file
However, you could use late-binding and avoid the reference issue.

NickHK

"Sajit" wrote in message
...
I want to create a set of VB statements that will set the object

references
required for my VBA code, such as, for the following,

Visual basic for applications
Microsoft Excel 11.0 Object Library
OLE Automation
Microsoft Office 11.0 Object Library
Microsoft Project 11.0 Object Library
Microsoft ActiveX Data Objects 2.8 Library
Microsoft ActiveX Data Objects Recordset 2.7 Library

Have them compiled to .exe and then call it at the start of my VBA code.

This is to create the references without the user having to do it

themselves.

I suppose it would be necessary to check whether the refernces are already
set, if so then skip this step.

Can someone please show me a few lines of, how to do this.

Thanks,
--
Sajit




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
Cell references in excel vba code Isis[_2_] Excel Discussion (Misc queries) 4 April 26th 10 01:10 PM
Help with VBA code - passing references to sheets? Rayo K Excel Programming 7 April 20th 06 06:51 PM
Line of Code to set references Myles[_60_] Excel Programming 5 April 7th 06 05:15 AM
Code that references the name of a cell pwrichcreek Excel Programming 8 February 6th 06 09:05 PM
Code to change references Steve[_27_] Excel Programming 0 August 4th 03 11:43 PM


All times are GMT +1. The time now is 11:04 AM.

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"