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

Hi,

How can I write code to include certain references when the workbook opens?

I use references like Microsoft ActiveX data object version 2.8, but my
customers dont always have the same up to date versions of excel.

From this they get hidden module errors. How can i write code so that if its
missing that it will pick up the same refernce but another version number eg
version 2.7

Thanks,
Jez

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default VBA References

Just make your code reference the lowest version. You should be referenceing
2.7 or 2.6. Since the references are backwards compatible your clients should
have no difficulty if they have 2.8. This is true for all code taht you write
for distribution. Code to the lowest common denominator, in terms of
references and Excel versions.
--
HTH...

Jim Thomlinson


"Jez" wrote:

Hi,

How can I write code to include certain references when the workbook opens?

I use references like Microsoft ActiveX data object version 2.8, but my
customers dont always have the same up to date versions of excel.

From this they get hidden module errors. How can i write code so that if its
missing that it will pick up the same refernce but another version number eg
version 2.7

Thanks,
Jez

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default VBA References

Thanks for that, but what code do I need to write in vb?

I asume that it would need to be writen in the Sub Workbook_open module but
how do I get it to reference these?

Thanks,
Jez


"Jim Thomlinson" wrote:

Just make your code reference the lowest version. You should be referenceing
2.7 or 2.6. Since the references are backwards compatible your clients should
have no difficulty if they have 2.8. This is true for all code taht you write
for distribution. Code to the lowest common denominator, in terms of
references and Excel versions.
--
HTH...

Jim Thomlinson


"Jez" wrote:

Hi,

How can I write code to include certain references when the workbook opens?

I use references like Microsoft ActiveX data object version 2.8, but my
customers dont always have the same up to date versions of excel.

From this they get hidden module errors. How can i write code so that if its
missing that it will pick up the same refernce but another version number eg
version 2.7

Thanks,
Jez

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 249
Default VBA References

Nothing.

Tools|References and check the box for 'Microsoft ActiveX Data Objects 2.x
Library'

Use the highest version that will still support your clients.

--

Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect

"Jez" wrote:
| Thanks for that, but what code do I need to write in vb?
|
| I asume that it would need to be writen in the Sub Workbook_open module
but
| how do I get it to reference these?
|
| Thanks,
| Jez


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default VBA References

If I dont have anything and just have the references that are in my
references, then when my clients use the report it comes up with hidden
module error because they dont have the same references as i do.

I want to write some code so that when the workbook opens it ignores any
references that are "Missing" and choose a lower module.

What can i write to get around this.

Thanks,
Jez

"Dave Patrick" wrote:

Nothing.

Tools|References and check the box for 'Microsoft ActiveX Data Objects 2.x
Library'

Use the highest version that will still support your clients.

--

Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect

"Jez" wrote:
| Thanks for that, but what code do I need to write in vb?
|
| I asume that it would need to be writen in the Sub Workbook_open module
but
| how do I get it to reference these?
|
| Thanks,
| Jez





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default VBA References

Try something like this:

Sub AddADO()

Dim R

For Each R In ThisWorkbook.VBProject.References
If R.GUID = "{00000205-0000-0010-8000-00AA006D2EA4}" And R.Major = 2
Then
Exit Sub
End If
Next

On Error GoTo NOTFOUND

'although usually the ADO version will be higher, doing Minor:=0 will
install
'the higher version if available. On the other hand when you specify
Minor:=5
'and only a lower version is available, this can't be installed
'----------------------------------------------------------------------------
ThisWorkbook.VBProject.References.AddFromGuid _
GUID:="{00000205-0000-0010-8000-00AA006D2EA4}", _
Major:=2, Minor:=0
Exit Sub

NOTFOUND:
On Error GoTo 0

End Sub


RBS


"Jez" wrote in message
...
Hi,

How can I write code to include certain references when the workbook
opens?

I use references like Microsoft ActiveX data object version 2.8, but my
customers dont always have the same up to date versions of excel.

From this they get hidden module errors. How can i write code so that if
its
missing that it will pick up the same refernce but another version number
eg
version 2.7

Thanks,
Jez


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 249
Default VBA References

That's why you want to back it down to a version that the clients have. You
don't need to write anything.

--

Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect

"Jez" wrote:
| If I dont have anything and just have the references that are in my
| references, then when my clients use the report it comes up with hidden
| module error because they dont have the same references as i do.
|
| I want to write some code so that when the workbook opens it ignores any
| references that are "Missing" and choose a lower module.
|
| What can i write to get around this.
|
| Thanks,
| Jez


  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default VBA References

As you may not have the lowest possible version on your own machine it is
best to save the wb without the reference
and add the reference in code as posted earlier.

RBS

"Dave Patrick" wrote in message
...
That's why you want to back it down to a version that the clients have.
You
don't need to write anything.

--

Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect

"Jez" wrote:
| If I dont have anything and just have the references that are in my
| references, then when my clients use the report it comes up with hidden
| module error because they dont have the same references as i do.
|
| I want to write some code so that when the workbook opens it ignores any
| references that are "Missing" and choose a lower module.
|
| What can i write to get around this.
|
| Thanks,
| Jez



  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 249
Default VBA References

Might be but in a situation where the lowest version on my dev machine (2.0)
is higher than anything on the client I would expect greater problems than
this would exist.

--

Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect

"RB Smissaert" wrote:
| As you may not have the lowest possible version on your own machine it is
| best to save the wb without the reference
| and add the reference in code as posted earlier.
|
| RBS


  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default VBA References

Sorry, didn't understand what you were saying there.

RBS

"Dave Patrick" wrote in message
...
Might be but in a situation where the lowest version on my dev machine
(2.0)
is higher than anything on the client I would expect greater problems than
this would exist.

--

Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect

"RB Smissaert" wrote:
| As you may not have the lowest possible version on your own machine it
is
| best to save the wb without the reference
| and add the reference in code as posted earlier.
|
| RBS





  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 249
Default VBA References

No problemo

--

Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect

"RB Smissaert" wrote:
| Sorry, didn't understand what you were saying there.
|
| RBS


  #12   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default VBA References

Thanks for this.

I dont mean to be thick but where would I put this code?

Do I put it in a module and call it in the Workbook_Open sub?

Also what happens if there are other references missing when my customers
open the report, how can I get around this.

Is there something I can do so that if any reference are missing it ignores
them?

When I open my report it automatically installs AddIns is there anything I
can do like this? AddIns("Analysis ToolPak").Installed = True

Thanks,
Jez


"RB Smissaert" wrote:

Try something like this:

Sub AddADO()

Dim R

For Each R In ThisWorkbook.VBProject.References
If R.GUID = "{00000205-0000-0010-8000-00AA006D2EA4}" And R.Major = 2
Then
Exit Sub
End If
Next

On Error GoTo NOTFOUND

'although usually the ADO version will be higher, doing Minor:=0 will
install
'the higher version if available. On the other hand when you specify
Minor:=5
'and only a lower version is available, this can't be installed
'----------------------------------------------------------------------------
ThisWorkbook.VBProject.References.AddFromGuid _
GUID:="{00000205-0000-0010-8000-00AA006D2EA4}", _
Major:=2, Minor:=0
Exit Sub

NOTFOUND:
On Error GoTo 0

End Sub


RBS


"Jez" wrote in message
...
Hi,

How can I write code to include certain references when the workbook
opens?

I use references like Microsoft ActiveX data object version 2.8, but my
customers dont always have the same up to date versions of excel.

From this they get hidden module errors. How can i write code so that if
its
missing that it will pick up the same refernce but another version number
eg
version 2.7

Thanks,
Jez



  #13   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default VBA References

Do I put it in a module and call it in the Workbook_Open sub?

Yes, that is an option.

Also what happens if there are other references missing when my customers
open the report, how can I get around this


Exactly the same, but of course with different GUID's.
I posted some code only about 2 weeks ago that will show you how to get
these GUID's.

Is there something I can do so that if any reference are missing it ignores
them?


Normally it can't be ignored.

AddIns("Analysis ToolPak").Installed = True


Yes, I think that would do it.

RBS

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
Tools | References - information about references L Mehl Excel Programming 6 July 4th 04 06:28 PM


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